huzi8t9
huzi8t9

Reputation: 292

Azure - Publish Web API - Compile

I'm trying to use a DevOps pipeline to deploy a Web API. I've got it working, looks great.

However, when the files are copied for the artifact, all of the source files are there too. When I use Visual Studio to "Publish" my Web API, there are minimal files, single Web.config (not Web.Release.config, Web.Debug.config)

Is there a way I can achieve this or, do I run a clean-up script to bin off the files I don't want there.

Example - published with Visual Studio: Published with Visual Studio

Example - published with Azure: Published with Azure

Edit: Created task group which goes through and deletes the unnecessary files and directories - not sure this is the correct approach but it does work.

enter image description here

Upvotes: 0

Views: 77

Answers (1)

Mehrdad
Mehrdad

Reputation: 1731

As you know, First of all you should publish your source on Azure e.g.

- task: UseDotNet@2
  inputs:
    packageType: 'sdk'
    version: '3.1.x'
- script: dotnet publish --self-contained -r win-x64
  displayName: 'dotnet build $(buildConfiguration)'

Then use your published files for your artifact. e.g.

bin/Debug/netcoreapp3.1/win-x64/publish

You don't need to remove anything for this purpose.

Upvotes: 1

Related Questions