Visual Studio. Publish project from command line

2019-01-30 04:17发布

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.

3条回答
戒情不戒烟
2楼-- · 2019-01-30 04:36

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

Got this from here: http://www.asp.net/mvc/tutorials/deployment/visual-studio-web-deployment/command-line-deployment

查看更多
你好瞎i
3楼-- · 2019-01-30 04:37

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.

查看更多
\"骚年 ilove
4楼-- · 2019-01-30 04:42

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

查看更多
登录 后发表回答