简体   繁体   中英

How to automate Visual Studio 2017 web project publish to folder

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);

msbuild MyProject.csproj /p:DeployOnBuild=true /p:PublishProfile=<profile-name> /p:Password=<insert-password> /p:VisualStudioVersion=15.2 

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;

DeploymentUnpublishable:
    Skipping unpublishable project.

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;

Microsoft Visual Studio Enterprise 2017
Version 15.2 (26430.16) Release

Any Ideas?

EDIT - Solution

@Leo-MSFT provided this solution...

msbuild myproject\myproject.vbproj /p:DeployOnBuild=true /p:PublishProfile=FolderProfile.pubxml /p:Configuration=Release

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.

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:

msbuild MyProject.csproj /p:DeployOnBuild=true /p:PublishProfile="MyProfile.pubxml"

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`sa issue for Visual Studio 2017, I will send this issue to Visual Studio team.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM