Fabio Milheiro
Fabio Milheiro

Reputation: 8474

VSO Copy website static files and binaries (not C# files)

I am trying to set up continuous integration on my server using Visual Studio online.

Created a new agent pool. Installed and configured a new build agent that I added to that agent pool. Then I trigger a new build of my code to be handled in my agent pool.

I manage to build it but how to set up the task "Copy and publish build artifacts".

My goal here is to just copy the final website files e.g. binaries, images, cshtml, but NOT all files such c# files. Well sort of like the "Right-click > publish" operation in visual studio.

What value do I need to enter in "Copy root" field? (please see image below)

enter image description here

Upvotes: 0

Views: 469

Answers (1)

Daniel Mann
Daniel Mann

Reputation: 59035

The documentation is located at: https://msdn.microsoft.com/en-us/Library/vs/alm/Build/scripts/variables

It all boils down to what the output path for your binaries is. If you're not overriding it via an MSBuild argument, $(Build.SourcesDirectory) with a value of **\bin\* will probably get you what you're after.

For a web application, make sure you're building with appropriate MSbuild arguments (something along the lines of /p:OutDir=$(build.stagingDirectory) /p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true should do the trick). This will get you a _PublishedWebsites folder in $(Build.StagingDirectory).

Then all you need to do is publish Copy Root of $(Build.StagingDirectory) and Contents of **\_PublishedWebsites\*

Keep in mind that Publish Build Artifacts means publish build artifacts to VSTS or a file share, not deploy build artifacts to a web server

Upvotes: 1

Related Questions