如何创建MSBuild目标文件来部署文件? [英] How to create MSBuild targets file to deploy files?
本文介绍了如何创建MSBuild目标文件来部署文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
\bin\out
中生成文件的后期构建过程,我如何使用MSBuild目标文件来声明所有文件(递归)在该目录应在Web部署期间发布?解决方案
我们将其分为两部分:
首先,构建Web项目:
< Target Name =BuildWeb>
< MSBuild Projects =WebExtranet\WebExtranet.csproj
Properties =Configuration = $(Environment); DeployOnBuild = True; CreatePackageOnPublish = True; BaseIntermediateOutputPath = .. \ $(DistDir) \\Web\/>
< / Target>
然后使用它发布到本地IIS(您可能需要调整msdeploy命令以适应您的需要)
< Target Name =DeployWeb>
< ItemGroup>
< PackageSourceDir Include ='$(DistDir)\Web\ $(Environment)\Package\WebExtranet.zip'/>
< / ItemGroup>
< Message Text =包路径:%(PackageSourceDir.FullPath)/>
< Exec Command =& quot; c:\Program Files\IIS\Microsoft Web Deploy V3 \msdeploy.exe&-verb:sync -allowUntrusted -source: package =& quot;%(PackageSourceDir.FullPath)" -setParam:'IIS Web Application Name'='我的Web App'-dest:auto/>
< / Target>
常见的陷阱:
- msbuild版本很重要。我正在使用V3。
- 您必须在IIS上创建Web应用程序。只需要执行一次。
请注意,$(Environment)变量是构建配置。我有几个,但运行第一个目标,并检查文件夹结构创建。然后调整脚本。
Given I have a post build process that generates files in \bin\out
how can I use a MSBuild targets file to state that all files (recursively) in that directory should be published during web deploy?
解决方案
Let's split this in two parts:
First, build the web project:
<Target Name="BuildWeb">
<MSBuild Projects="WebExtranet\WebExtranet.csproj"
Properties="Configuration=$(Environment);DeployOnBuild=True;CreatePackageOnPublish=True;BaseIntermediateOutputPath=..\$(DistDir)\Web\" />
</Target>
Then use this to publish to the local IIS (you might need to adjust the msdeploy command to suit your needs)
<Target Name="DeployWeb">
<ItemGroup>
<PackageSourceDir Include='$(DistDir)\Web\$(Environment)\Package\WebExtranet.zip' />
</ItemGroup>
<Message Text="Package path: %(PackageSourceDir.FullPath)" />
<Exec Command=""c:\Program Files\IIS\Microsoft Web Deploy V3\msdeploy.exe" -verb:sync -allowUntrusted -source:package="%(PackageSourceDir.FullPath)" -setParam:'IIS Web Application Name'='My Web App' -dest:auto"/>
</Target>
Common pitfalls:
- The msbuild version is important. I'm using V3.
- You have to have the web application already created on IIS. Only need to do it once.
Note that the $(Environment) variable is the build configuration. I have several, but run the first target and check the folder structure created. Then adjust the script.
这篇关于如何创建MSBuild目标文件来部署文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文