开发者

Visual Studio. Publish project from command line

开发者 https://www.devze.com 2022-12-29 01:27 出处:网络
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.

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 publi开发者_运维知识库sh 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.


From ASP.NET Web Deployment using Visual Studio: Command Line Deployment, you can use

msbuild myproject.csproj /p:DeployOnBuild=true /p:PublishProfile=MyPublishProfile

where MyPublishProfile is the profile name that you've already set up somewhere


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.


The /t:publish switch is for ClickOnce applications only, it's not applicable to web projects. Hence the error saying it's unpublishable. :)

0

精彩评论

暂无评论...
验证码 换一张
取 消