bitshift
bitshift

Reputation: 6842

Azure pipeline to build & publish web app and windows service (on prem) within a single solution

Have a .net framework solution with several projects (1) a windows service, (2) web app and (3) a shared class library. I need to build and publish the windows service along with the web app since they share the same class library. I am new to yaml but still not very familiar with azure build pipelines either.

Already have the deployment group setup with the agent installed on the target server where this build is targeting.

I understand the basic process I need to do

Then in a release pipeline:

With a new build pipeline, choosing the ".NET Desktop" template, you get a build task that looks like this

- task: VSBuild@1
  inputs:
    solution: '$(solution)'  
    platform: '$(buildPlatform)'
    configuration: '$(buildConfiguration)'

Questions:
(1) In the build task for the windows service, how do I get the binaries zipped into a drop folder?
One example I seen was setting the msBuildArgs setting to something like this:

msBuildArgs:"/p:OutputPath='$(Build.BinariesDirectory)\$(Build.BuildId)'"

(2) How does one update the connection strings in the app.config and should that be done here or in the release pipeline?

Upvotes: 1

Views: 2583

Answers (1)

PaulVrugt
PaulVrugt

Reputation: 1882

There is no need for a separate release pipeline. You should create a single pipeline, with 2 stages. The first will build the solution, and publish the artifacts. See https://learn.microsoft.com/en-us/azure/devops/pipelines/tasks/utility/publish-pipeline-artifact?view=azure-devops. There is no need to zip anything. The pipeline artifacts task will take care of zipping transparently. Also, there is no separate build task for the windows server. You use the build task you mentioned to build the entire solution

The second stage should run on the agent on the target server. You should download the pipeline artifacts (see https://learn.microsoft.com/en-us/azure/devops/pipelines/tasks/utility/download-pipeline-artifact?view=azure-devops) and performs the deployment tasks you listed.

You can update the connection string using a powershell script in the release stage, since in this stage you actually know to what environment you are deploying to

Upvotes: 1

Related Questions