2010-02-23 92 views
0

我一直在研究如何將部署操作添加到我的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

我認爲你需要使用輸出元素在你的DeploymentParameters任務:http://msdn.microsoft.com/en-us/library/ms164287.aspx – 2010-02-23 19:13:55

+0

@Jim它出現在輸出元素是子像'Exec'或'Csc'這樣的任務的元素。 – Dave 2010-02-23 19:17:03

+0

是的,我看起來更接近一點。在我的腳本中,而不是條件屬性,我有條件Exec命令,但這正是你顯然想要避免的。 – 2010-02-23 19:21:03

回答

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> 
相關問題