title: How to automate Visual Studio 2017 web project publish to folder
body: <p>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. </p>
  
  <p>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.</p>
  
  <p>I have tried the recommendation on <a href="http://sedodream.com/2013/01/06/CommandLineWebProjectPublishing.aspx" rel="noreferrer">Sayed Hashimi's</a> 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);</p>
  
  <pre><code>msbuild MyProject.csproj /p:DeployOnBuild=true /p:PublishProfile=&lt;profile-name&gt; /p:Password=&lt;insert-password&gt; /p:VisualStudioVersion=15.2 
  </code></pre>
  
  <p>But this did not put any files in the <code>bin\Release\PublishOutput</code> location. It looked like it just did a standard build.</p>
  
  <p><strong>EDIT:</strong> </p>
  
  <p>msbuild lists this line in the output when I run the above command;</p>
  
  <pre><code>DeploymentUnpublishable:
      Skipping unpublishable project.
  </code></pre>
  
  <p>I have looked through <a href="https://github.com/Microsoft/msbuild/issues/1901" rel="noreferrer">this</a> post on GitHub and some have cited a solution as updating to v15.2 of VS2017, which I have already done;</p>
  
  <pre><code>Microsoft Visual Studio Enterprise 2017
  Version 15.2 (26430.16) Release
  </code></pre>
  
  <p>Any Ideas?</p>
  
  <p><strong>EDIT - Solution</strong></p>
  
  <p>@Leo-MSFT provided this solution...</p>
  
  <pre><code>msbuild myproject\myproject.vbproj /p:DeployOnBuild=true /p:PublishProfile=FolderProfile.pubxml /p:Configuration=Release
  </code></pre>
  
  <p>This put the files into bin\release\PublishOutput.</p>
  
  <p>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 <code>/t:Publish</code>, <code>/p:PublishProfileRootFolder</code> and <code>/p:VisualStudioVersion=15.2</code>. I removed those and just used the line above which finally created the published output I needed.</p>