Search code examples
visual-studiocommand-linevisual-studio-2010

Visual Studio. Publish project from command line


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.


Solution

  • 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.