visual-studio 视觉工作室。从命令行发布项目
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2774955/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Visual Studio. Publish project from command line
提问by sha
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.
有没有办法使用 CLI 在 MS Visual Studio 2010 中发布 Web 项目?我使用 DevEnv.exe /Build 来构建一个项目并且它工作正常,但我找不到发布项目的选项。
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.
我想提的另一件事。我正在尝试将 Web 项目发布到不直接发布到 IIS。我有一个位置可以发布多个项目,然后将它们自动构建到 NSIS 包中进行部署。
采纳答案by sha
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.
这样,每当项目构建(从命令行或从 IDE)时,它都会自动部署到指定的文件夹。谢谢大家为我指出正确的方向。
回答by dten
From ASP.NET Web Deployment using Visual Studio: Command Line Deployment, you can use
从ASP.NET Web Deployment using Visual Studio: Command Line Deployment,您可以使用
msbuild myproject.csproj /p:DeployOnBuild=true /p:PublishProfile=MyPublishProfile
where MyPublishProfileis the profile name that you've already set up somewhere
MyPublishProfile您已经在某处设置的配置文件名称在哪里
回答by Ted Nyberg
The /t:publishswitch is for ClickOnce applications only, it's not applicable to web projects. Hence the error saying it's unpublishable. :)
该/吨:发布开关是ClickOnce应用程序只,它并不适用于Web项目。因此,错误说它不可发布。:)

