4

When I started writing this question, my problem was that after a successful VSTS Build, I wasn't able to see the files relating to my web application project for release. Only the files from certain other projects in the solution were present. However, I just came across this question, which has helped.

I can now see the compiled .dll files for my web application project, after altering the configuration of the Content setting in the Build - that is, the contents of the Bin folder under that project. But I can't see anywhere the other files I need to copy the built web application to my server - the views, the scripts, the css, etc.

I'm finding the power and flexibility of VSTS's Build and Release functionality very confusing as it's complete overkill for our requirements. Up until now, I've just right-clicked on the web app project in Visual Studio selected Publish and used the File System publish method. Easy. Now that I want to automate the building and deploying of the application, it's many times more complicated!

So, can anybody tell me how I can get the solution to build in VSTS in such a way that I can then use a Copy Files task in the Release Definition to copy the files to our web server (the server isn't visible to the Internet so I'm using a locally-hosted Agent)?

Community
  • 1
  • 1
Philip Stratford
  • 4,513
  • 4
  • 45
  • 71
  • If you're using that MSBuild flag from the other question, you should see a "_PublishedWebsites" folder in your drop folder. Inside that folder, you should see an application folder with all the files that you need to deploy to your web server. Are you seeing any of that? – Jim Roth Oct 18 '16 at 14:53
  • I was actually following the advice in the second answer, posted by JimiSweden. I didn't use the MSBuild switches because the poster said they were for creating a WebDeploy package, whereas I just want the files to copy directly to the web server. Do you know which of the switches will result in the "_PublishedWebsites" folder? – Philip Stratford Oct 18 '16 at 15:12
  • 1
    Not to worry, I found it in the comments further down - it's the /p:outdir=$(build.artifactstagingdirectory) switch. Giving it a try now. – Philip Stratford Oct 18 '16 at 15:37

2 Answers2

3

In vNext build, to publish your build artifacts with the Copy files or Publish build artifacts steps. Try to use the local path on the agent where any artifacts are copied to before being pushed to their destination. For example:

  1. Add /p:DeployOnBuild=true /p:OutDir="$(build.artifactstagingdirectory)\" arguments in Visual Studio Build step;
  2. Change "Path to Publish" of Publish Build Artifacts task to $(build.artifactstagingdirectory)\_PublishedWebsites\ProjectName:

Details please check the screenshot of build step with this question: How do I get the the expected output from a TFS 2015 build (to match my XAML build)?

Community
  • 1
  • 1
PatrickLu-MSFT
  • 49,478
  • 5
  • 35
  • 62
  • 1
    Thanks for your help. I think I've basically achieved the same thing by updating the Source parameter of the Copy Files task in the Release Definition to point to the PublishedWebsites\ProjectName folder, although I can see that your way is more efficient. I'm completely stuck with Build/Release in VSTS. In VS I just right-click the application Project, choose Publish and it outputs the required files to the share on the server. The Build function in VSTS seems to output something similar but different. It includes multiple versions of web.config, for example, and no PrecompiledApp.config. – Philip Stratford Oct 19 '16 at 12:27
  • @PhilipStratford Which publish method do you select when publish from Visual Studio? – Eddie Chen - MSFT Oct 20 '16 at 07:28
  • @Eddie-MSFT I use the File System method, and set the destination to the share on my web server. – Philip Stratford Oct 20 '16 at 09:00
  • @PhilipStratford Then do you have a publish profile in your project with these publish settings? – Eddie Chen - MSFT Oct 20 '16 at 09:09
  • I do, a publish profile which works locally from Visual Studio, I just wanted to replicate the publish process in VSTS. However, even though my built web application still looks slightly different in VSTS than VS, I've now managed to get this working. I realised that the transformation for my specified configuration wasn't working so various settings from the wrong web.config file were being used. Now that I've got the transformation taking place as part of the build process in VSTS everything is working. – Philip Stratford Oct 20 '16 at 14:13
  • should we include bin folder into the source control, for vNext build? please answer https://stackoverflow.com/q/63059180/10846390 – Saad Awan Aug 19 '20 at 12:02
0

Base on your comments, you have published the web app from Visual Studio. Usually, this action will generate a publish profile under Project/Properties/PublishProfiles folder. The settings you used to publish the web app is stored in the profile. So you just need to make sure this publish profile is checked into source control. And then in the TFS build, add following MSBuild arguments:

/p:DeployOnBuild=true /p:PublishProfile="publishprofile.pubxml"
Eddie Chen - MSFT
  • 29,708
  • 2
  • 46
  • 60