dapperdandev
dapperdandev

Reputation: 3298

What Changes to my VSTS build need to be made for .net core Web Api Deploy to Azure

I'm attempting to use VSTS to build and deploy my .net core Web API Web App Service.

It appears that previous versions of .net (including somewhat recent versions of .net core) created a zip file. The default configuration for an Azure App Service Deploy have the field Package or Folder set to $(System.DefaultWorkingDirectory)/**/*.zip by default. This was failing for me with the error No package found with specified pattern: D:\a\1\s\**\*.zip

I was able to get it to kind of succeed by changing the path to simply $(System.DefaultWorkingDirectory), but from the Azure console I can see that this deploys everything (not just the binaries)

I could add a trainload of questions following this, but I'll keep this specific.

P.s.> I already looked here: dotnet publish command is not creating zip file package for asp.net core web application project, but it appears to be a different problem

Upvotes: 0

Views: 532

Answers (2)

starian chen-MSFT
starian chen-MSFT

Reputation: 33708

You can check Zip Published Projects option of .NET Core Publish task and specify output argument (--output $(build.artifactstagingdirectory)

enter image description here

Then the Web API project will be published and zipped to a package in the artifact directory, after that you can specify $(build.artifactstagingdirectory)/**/*.zip in Package or Folder input box if you deploy the app during the same build.

Upvotes: 1

Alexander S.
Alexander S.

Reputation: 844

I am not fully understand the questions, but I can give your some suggestion points.

1. Clean Sources

On "Get Sources" step choose Clean -> true -> Sources and Output. This will ensure cleaning all old code.

2. Create package

After build use "dotnet publish" step. In "Path to project(s)" as POC I recommend to set path to your project:

{Your Solution}/{Your Project}/{Your Project}.csproj

You don't need to add "$(System.DefaultWorkingDirectory)" it is automatically added to path your enter. This will create package.zip file.

3. Copy package

Use "Copy Files" step. For "Target Folder" choose $(build.artifactstagingdirectory). As pattern set "**/*.zip". This will ensure, that only package files will be used for deploy.

4. Deploy package

Use "Azure App Service Deploy". As "Package or Folder" choose one of

$(build.artifactstagingdirectory)/**/*.zip

$(build.artifactstagingdirectory)/{Your Solution}/{Your Project}/**/*.zip

Hope it helps.

Upvotes: 0

Related Questions