views:

177

answers:

2

Is there a way to publish a web project in MS Visual Studio 2010 using CLI? I use DevEnv.exe /Build to build a project and it works fine, but I could not find option to Publish a project.

One other thing I want to mention. I am trying to publish web project NOT to the IIS directly. I have a location where I publish several projects and then build them automatically into NSIS bundle to be deployed.

A: 

MSBuild (which I believe ships with VS) provides a publish command line option:

msbuild /t:publish yourproject.csproj
David Lively
Looks like it skips my project saying:D:\Dev\Project>msbuild /t:publish "Project.csproj"Microsoft (R) Build Engine Version 3.5.30729.4926[Microsoft .NET Framework, Version 2.0.50727.4927]Copyright (C) Microsoft Corporation 2007. All rights reserved.Build started 5/5/2010 10:06:58 AM.Project "D:\Dev\Project\Project.csproj" on node 0 (publish target(s)). Skipping unpublishable project.Done Building Project "D:\Dev\Project\Project.csproj" (publish target(s)).Build succeeded. 0 Warning(s) 0 Error(s)Time Elapsed 00:00:00.00
sha
+2  A: 

What works best is to add following target to the project file:

<Target Name="AfterBuild">
   <Message Text="Copying to Deployment Dir:" />
   <Copy SourceFiles="@(Content)" DestinationFolder="..\XXX\%(Content.RelativeDir)" />
      <CreateItem Include="$(OutputPath)\*">
        <Output TaskParameter="Include" ItemName="Binaries"/>
      </CreateItem>
   <Copy SourceFiles="@(Binaries)" DestinationFolder="..\XXX\bin" />
</Target>

This way, whenever project got build (from command line or from IDE) it automatically get deployed to specified folder. Thank you everybody for pointing me to right direction.

sha