I am trying to publish an azure webjob from the command line but it does not actually deploy to azure.
I am able to successfully publish using Visual Studio 2019 using the Publish... option. VS2019 builds, publishes and deploys.
My command line attempt seems to build and publish, but no deploy.
The command line I am using is:
dotnet.exe publish Events.WebJob.csproj --verbosity n /p:PublishProfile="hssedapi-dev-webdeploy" /p:Password="${apipwd}" /p:UseAppHost=true
dotnet --version returns "2.2.202"
I found "Develop and deploy WebJobs using Visual Studio - Azure App Service" which is fairly current. It has a link to "Enabling Command-line or Continuous Delivery of Azure WebJobs" but it is from 2014.
The following Publish methods are currently supported by the Publish package:
·Folder Publish
·MsDeploy Publish
·MsDeploy Package Publish
According to the code you provided, you use the MsDeploy Publish. Profile can be added to the following location in the project /Properties/PublishProfiles/<MsDeployProfile.pubxml>. Here is sample MsDeploy Publish Profile:
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<WebPublishMethod>MSDeploy</WebPublishMethod>
<PublishProvider>AzureWebSite</PublishProvider>
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
<LastUsedPlatform>Any CPU</LastUsedPlatform>
<SiteUrlToLaunchAfterPublish>http://webappwithdb.azurewebsites.net</SiteUrlToLaunchAfterPublish>
<LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
<MSDeployServiceURL>webappwithdb.scm.azurewebsites.net:443</MSDeployServiceURL>
<DeployIisAppPath>webappwithdb</DeployIisAppPath>
<SkipExtraFilesOnServer>True</SkipExtraFilesOnServer>
<MSDeployPublishMethod>WMSVC</MSDeployPublishMethod>
<EnableMSDeployBackup>True</EnableMSDeployBackup>
<UserName>$vramakwebappwithdb</UserName>
<Password>DeployPassword</Password>
</PropertyGroup>
</Project>
Related
I'm trying to use Azure DevOps Pipelines to build my .NET Core 2.1 solution from GitHub. It includes a SQL project that has a TargetFrameworkVersion of v4.6.2. This project always fails to build.
Build FAILED.
/home/vsts/work/1/s/MySolution/MyDatabase/MyDatabase.sqlproj : warning NU1503: Skipping restore for project '/home/vsts/work/1/s/MySolution/MyDatabase/MyDatabase.sqlproj'. The project file may be invalid or missing targets required for restore. [/home/vsts/work/1/s/MySolution/MySolution.sln]
/home/vsts/work/1/s/MySolution/MyDatabase/MyDatabase.sqlproj(57,3): error MSB4019: The imported project "/usr/share/dotnet/sdk/2.1.403/Microsoft/VisualStudio/v15.0/SSDT/Microsoft.Data.Tools.Schema.SqlTasks.targets" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.
1 Warning(s)
1 Error(s)
How do I reference or include those targets for the build server? It builds fine in VS2017. I've spent more than a day hunting and cannot find any information on this problem.
Thanks to Herman Cordes for directing my investigation.
The problem was the selected build server. SSDT is a Windows-only package, so I had to use a Windows VM instead of the default Ubuntu VM, and use the VSBuild#1 task instead of DotNetCoreCLI#2.
azure-pipelines.yml
pool:
vmImage: 'vs2017-win2016'
steps:
- task: VSBuild#1
displayName: 'vsbuild $(buildConfiguration)'
inputs:
configuration: $(buildConfiguration)
EDIT: The MSBuild#1 task also works.
Here is a solution for linux build agent
Easiest way to build DacPac file on a linux agent is done via MSBuild.Sdk.SqlProj
Go to your database project directory in parallel to .sqlproj file create a directory like DB.Build under it create DB.Build.csproj copy.pase the content as below
<Project Sdk="MSBuild.Sdk.SqlProj/1.1.0"> <!-- This will pull in the required tools and dependencies to build a .dacpac with .NET Core -->
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<Content Include="..\src\DB\masterdata\**\*.sql" /> <!-- link in the new .csproj to the .sql scripts in your existing database project -->
</ItemGroup>
</Project>
After run you will see dacpac file appears under DB.Build/bin/Release/netstandard2.0/DB.Build.dacpac
Here's my build agent output (Ubuntu agent on Azure devops)
Starting: SQL DB build Release
==============================================================================
Task : .NET Core
Description : Build, test, package, or publish a dotnet application, or run a custom dotnet command
Version : 2.187.0
Author : Microsoft Corporation
Help : https://learn.microsoft.com/azure/devops/pipelines/tasks/build/dotnet-core-cli
==============================================================================
Info: .NET Core SDK/runtime 2.2 and 3.0 are now End of Life(EOL) and have been removed from all hosted agents. If you're using these SDK/runtimes on hosted agents, kindly upgrade to newer versions which are not EOL, or else use UseDotNet task to install the required version.
/opt/hostedtoolcache/dotnet/dotnet build /home/vsts/work/1/s/src/RecommenderAPI.DB/RecommenderAPI.DB/RecommenderAPI.DB.Build/RecommenderAPI.DB.Build.csproj -dl:CentralLogger,"/home/vsts/work/_tasks/DotNetCoreCLI_5541a522-603c-47ad-91fc-a4b1d163081b/2.187.0/dotnet-build-helpers/Microsoft.TeamFoundation.DistributedTask.MSBuild.Logger.dll"*ForwardingLogger,"/home/vsts/work/_tasks/DotNetCoreCLI_5541a522-603c-47ad-91fc-a4b1d163081b/2.187.0/dotnet-build-helpers/Microsoft.TeamFoundation.DistributedTask.MSBuild.Logger.dll" --configuration Release /p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation=/home/vsts/work/1/recommender-service-cicd/DacPac/
Microsoft (R) Build Engine version 16.5.0+d4cbfca49 for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.
Restore completed in 51.72 ms for /home/vsts/work/1/s/src/RecommenderAPI.DB/RecommenderAPI.DB/RecommenderAPI.DB.Build/RecommenderAPI.DB.Build.csproj.
Using package name RecommenderAPI.DB.Build and version 1.0.0
Using SQL Server version Sql150
Deleting existing file /home/vsts/work/1/s/src/RecommenderAPI.DB/RecommenderAPI.DB/RecommenderAPI.DB.Build/obj/Release/netstandard2.0/RecommenderAPI.DB.Build.dacpac
Writing model to /home/vsts/work/1/s/src/RecommenderAPI.DB/RecommenderAPI.DB/RecommenderAPI.DB.Build/obj/Release/netstandard2.0/RecommenderAPI.DB.Build.dacpac
RecommenderAPI.DB.Build -> /home/vsts/work/1/s/src/RecommenderAPI.DB/RecommenderAPI.DB/RecommenderAPI.DB.Build/bin/Release/netstandard2.0/RecommenderAPI.DB.Build.dacpac
Build succeeded.
0 Warning(s)
0 Error(s)
Time Elapsed 00:00:01.71
Finishing: SQL DB build Release
Note: Make sure to restore you NuGet packages in step prior to build
Your ADO pipeline manifest should look like this:
...
- task: DotNetCoreCLI#2
displayName: 'Restore SQL Project'
inputs:
command: 'restore'
projects: '**/*DB*/*.csproj'
feedsToUse: 'select'
vstsFeed: 'db-feed'
...
- task: DotNetCoreCLI#2
displayName: 'SQL DB build $(buildConfiguration)'
inputs:
command: build
projects: '**/*DB*/*.csproj'
platform: '$(buildPlatform)'
arguments: '--configuration $(buildConfiguration) /p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation=$(Pipeline.Workspace)/$(pipelineArtifactName)/DacPac/'
I was having the exact same issue building a SQL Server project on an Azure DevOps CI/CD pipeline. None of the pre-built build tasks would work for me!
I solved this by avoiding to add a SQL Server project to the solution.
I achieved this by using an MSBuild SDK, capable of producing a SQL Server Data-Tier Application package (.dacpac) from the set of SQL scripts. By adding this second project to the solution, I managed to continue taking advantage of linking the project to a live database through SQL Server Object Explorer on Visual Studio. I gave a more detailed explanation about my implementation in this answer.
I have used .Net Core 2.0 to build my Web API. Now I am trying to deploy this project to AWS using its Elastic Beanstalk Service. I am also using the Visual Studios AWS deployment tool.
During the deployment process, I am receiving the following error;
Error during deployment: Could not find a part of the path
'C:\inetpub\AspNetCoreWebApps\app\appsettings.Development.json'.
I have added the following section into my .csproj;
<ItemGroup>
<Content Update="appsettings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Update="appsettings.Development.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
I can see that my appsettings.json and appsettings.Development.json are in my output folder when I build my project. Also they appear in the published directory if I publish the app into my local pc.
I could not understand why does Amazon's service can not pick it up...
Edit: So, interestingly I created a new .Net Core 2.0 Web Api project from Visual Studio templates and tried deploying it to AWS and it gave me the same error. However when I create an MVC project and deploy it to AWS everything works fine. The default settings for the web api template seems to be effecting the deployment somehow...
So I created a new .Net Core 2.0 MVC Project and migrated/adapted my web api to it. Now its deployed without any issues.
So if your project was started from a Web Api template and getting a simillar error, try switching between templates.
So after trial and error with including and excluding certain files, the problem is with WebApi because it does not have a wwwroot folder and it would appear the elastic beanstalk scripts are looking for this.
To make it work, I added a wwwroot folders and put a placeholder html file inside it and my project now deploys correctly!
Are you using AWS toolkit for VS 2017 to deploy your application. That would do a lot of the config work for you.
There are many problems with the AWS preconfigured environment for asp.net core 2 with IIS 10, try terminating your beanstalk environment and recreate and deploy through AWS toolkit directly from Visual Studio. Right click your project and use the "Publish to AWS Beanstalk"
I am getting below error while building my project. It seems I am missing data tool components on my build agent
No agent found in pool Hosted VS2017 which satisfies the specified
demands: sqlpackage Agent.Version -gtVersion 1.103.0
But I am unable to get offline installer for data tools for VS 2017. Please help.
The sqlpackage.exe is existing on Hosted VS 2017 agent, but not in the capacity list. (can’t add this capacity manually and use deploy database task, check VS2017 Hosted Agent: SQL Server Data Tools)
The workaround is that you can call sqlpackage.exe command by using Command Line task:
Right click your project > Publish to create a publish profile
Edit that publish profile to add Password to TargetConnectionString (Could be tokenized by using Replace Tokens task)
Sample:
<TargetConnectionString>Data Source=XXX.database.windows.net,1433;Persist Security Info=True;User ID=XXX;Password=XXX;Pooling=False;MultipleActiveResultSets=False;Connect Timeout=60;Encrypt=False;TrustServerCertificate=True</TargetConnectionString>
Check in changes
Add Command line task: (Tool: C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\Extensions\Microsoft\SQLDB\DAC\130\sqlpackage.exe; Arguments: /Action:Publish /SourceFile:"$(build.artifactstagingdirectory)\DatabaseDemo.dacpac" /Profile:"$(build.sourcesdirectory)\DatabaseDemo\DatabaseDemo.publish.xml")
Queue build with Hosted VS2017 agent.
I need to create something like the BasicAuthHandler proposed on the WSO2 ESB documentation but using the WSO2 Developer Studio. On the WSO2 ESB documentation they suggest downloading one existing example but don't gives any clue about howto make it using WSO2 Developer Studio. Is not the WSO2 Developer Studio the right way of developing custom code for the WSO2 Carbon platform?
Steps:
Download the code
Run mvn clean install -e
Import the code as a maven project using the WSO2 Developer Studio 3.8.0
It work fine for me.
Please check that you have org.apache.synapse:synapse-core:jar:2.1.1-wso2v2 in your maven repo. you can add a wso2 maven repo to your pom.xml file:
<repositories>
<repository>
<id>wso2-maven2-repository</id>
<url>http://dist.wso2.org/maven2</url>
</repository>
</repositories>
I have an automated build in Visual Studio Team Services (formerly Visual Studio Online. The solution is building correctly. How do I configure it so it will also create a web deploy package?
We use the following MSBuild Arguments: /p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="$(build.artifactstagingdirectory)\\"
With these you do not need to create a new publishing profile.
We enable web deploy package creation within the "Visual Studio Build" task. Simply pass the following MS Build arguments:
MSBuild Arguments: /p:DeployOnBuild=true;PublishProfile=<name of your profile>