我一直在努力将部署操作添加到我的Web项目文件中,以便我可以从TeamCity部署Web项目。如何附上和步骤以便我不需要重复条件检查?
<Target Name="Deploy">
<PropertyGroup Condition=" '$(Configuration)' == 'Development-Publish' ">
<ScriptPath>c:\scripts\development.txt</ScriptPath>
<DeploymentPath>\\devserver\dev</DeploymentPath>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Integration-Publish' ">
<ScriptPath>c:\scripts\integration.txt</ScriptPath>
<DeploymentPath>\\integrationserver\int</DeploymentPath>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Staging-Publish' ">
<ScriptPath>c:\scripts\staging.txt</ScriptPath>
<DeploymentPath>\\stagingserver\staging</DeploymentPath>
</PropertyGroup>
<PropertyGroup>
<BeyondCompareCommand>C:\Program Files\Beyond Compare 3\BCompare.exe</BeyondCompareCommand>
<AdditionalArguments>/silent /closescript</AdditionalArguments>
<DeploymentCommand>"$(BeyondCompareCommand)" @"$(ScriptPath)" "$(WebProjectOutputDir)" "$(DeploymentPath)" $(AdditionalArguments)</DeploymentCommand>
</PropertyGroup>
<Message Condition=" '$(DeploymentPath)' != '' " Importance="high" Text="Executing Deployment with this command: $(DeploymentCommand)" />
<Exec Condition=" '$(DeploymentPath)' != '' " Command="$(DeploymentCommand)" />
</Target>
我认为我应该<Target Name="DeploymentParameters"/>
<Target Name="Deploy" DependsOnTargets="DeploymentParameters"/>
,但除非我犯了错误,否则我无法访问DeploymentParameters
目标中声明的属性。
答案 0 :(得分:0)
<PropertyGroup Condition=" '$(Configuration)' == 'Development-Publish' ">
<ScriptPath>c:\scripts\development.txt</ScriptPath>
<DeploymentPath>\\devserver\dev</DeploymentPath>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Integration-Publish' ">
<ScriptPath>c:\scripts\integration.txt</ScriptPath>
<DeploymentPath>\\integrationserver\int</DeploymentPath>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Staging-Publish' ">
<ScriptPath>c:\scripts\staging.txt</ScriptPath>
<DeploymentPath>\\stagingserver\staging</DeploymentPath>
</PropertyGroup>
<PropertyGroup>
<BeyondCompareCommand>C:\Program Files\Beyond Compare 3\BCompare.exe</BeyondCompareCommand>
<AdditionalArguments>/silent /closescript</AdditionalArguments>
<DeploymentCommand>"$(BeyondCompareCommand)" @"$(ScriptPath)" "$(WebProjectOutputDir)" "$(DeploymentPath)" $(AdditionalArguments)</DeploymentCommand>
</PropertyGroup>
<Target Name="Deploy" Condition=" '$(DeploymentPath)' != '' " >
<Message Importance="high" Text="Executing Deployment with this command: $(DeploymentCommand)" />
<Exec Command="$(DeploymentCommand)" />
</Target>