How to automate Visual Studio 2017 web project publish to folder

Question:

I am trying to create a PowerShell v5 script to build and publish a VS2017 WCF Web Service Application (.NET Framework 4) so that I can automate it in Bamboo. I have the msbuild command working that does the build correctly and now I need to publish the project to a folder using a FolderProfile.

I can do it manually with success by right-clicking on the project and selecting publish, then selecting the FolderProfile. This puts the files that need to be deployed to the website in the project’s bin\Release\PublishOutput location. I want to automate that publishaction in a Powershell script.

I have tried the recommendation on Sayed Hashimi’s site, which is similar to below (I just use VS2017 version of 15.2, and, of course, replace the project name and profile with my actual values);

But this did not put any files in the bin\Release\PublishOutput location. It looked like it just did a standard build.

EDIT:

msbuild lists this line in the output when I run the above command;

I have looked through this post on GitHub and some have cited a solution as updating to v15.2 of VS2017, which I have already done;

Any Ideas?

EDIT – Solution

@Leo-MSFT provided this solution…

This put the files into bin\release\PublishOutput.

I had spent several days searching for this solution and I had added various command parameters suggested in other SO and GitHub forum posts, such as /t:Publish, /p:PublishProfileRootFolder and /p:VisualStudioVersion=15.2. I removed those and just used the line above which finally created the published output I needed.

Answer:

this did not put any files in the bin\Release\PublishOutput location. It looked like it just did a standard build

I have reproduced this issue with your command line. After research this issue for a long time, I try to remove the parameter “/p:VisualStudioVersion=15.2“, then re-publish the project with the command line:

It build and publish successfully, and web project publish to folder where you set in the option “<publishUrl>” in MyProfile.pubxml.

So please try to remove the parameter “/p:VisualStudioVersion” in the MSBuild command line, check if it works for you.

Note: I have also test that command line with VisualStudioVersion for the project created by the Visual Studio 2015, it works fine. Not sure whether this is a issue for Visual Studio 2017, I need to confirm it, if it`s a issue for Visual Studio 2017, I will send this issue to Visual Studio team.

Source:

How to automate Visual Studio 2017 web project publish to folder by licensed under CC BY-SA | With most appropriate answer!

Leave a Reply