How to automate Visual Studio 2017 web project publish to folder
Asked Answered
A

1

7

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.

Abbottson answered 28/7, 2017 at 16:15 Comment(0)
S
8

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

Strouse answered 31/7, 2017 at 8:29 Comment(3)
This solved the issue perfectly. My final command line ended up as msbuild myproject\myproject.vbproj /p:DeployOnBuild=true /p:PublishProfile=FolderProfile.pubxml /p:Configuration=Release. This put the files into bin\release\PublishOutput. ThanksAbbottson
This also solved my issue (in addition to using the right msbuild). With previous versions of VS I used to call C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe and provide the /p:VisualStudioVersion parameter. Now with VS 2017 Community I call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\msbuild.exe" without the VisualStudioVersion parameter, and it worksPlaylet
this doesn't take care of web.config TransformAnsate

© 2022 - 2024 — McMap. All rights reserved.