2014-01-14 45 views
0

我有兩個MVC項目。我創建了兩個WindowsAzure項目:WindowsAzure1->哪個包MVC1和WindowsAzure2->哪個包MVC2項目。在本地TFS 2012簽入後,我構建了我的解決方案。 MSBuild的參數:Windows Azure項目替換ServiceConfiguration.Cloud.cscfg

/噸:發佈/ P:PublishDir = C:\滴\ app.publish \

生成後我看到3文件中,而不是4

1 .WindowsAzure1.cspkg 2.WindowsAzure2.cspkg 3.ServiceConfiguration.Cloud.cscfg //它包含配置WindowsAzure2.cspkg

我試圖重命名ServiceConfiguration.Cloud.cscfg,但它不重命名。 所以,我認爲更好的地方包在不同的文件夾。但問題是未來的MVC和Azure項目將不得而知。所以我需要自動創建文件夾包含名稱項目。那它怎麼辦?

回答

1

創建動態文件夾的簡單方法是通過PowerShell腳本。

比方說你有項目文件夾結構下面的方式 - enter image description here

然後你就可以按照腳本來生成包文件夾 -

# Solution directory, which contains all the projects 
$path = "C:\Solution" 
$folders = Get-ChildItem -Path $path 

foreach ($folder in $folders) 
{ 
     if ($folder.Attributes -eq "Directory") 
     { 
      if($folder.Name -like "*.Cloud") 
      { 
       New-Item -Path "$($path)\$($folder.Name)package" -ItemType "Directory" 
      } 
     } 
} 

輸出將是 - enter image description here

然後您可以使用CSPack實用程序和PowerShell組合來創建包並將配置文件保存到您感興趣的位置。

http://www.intstrings.com/ramivemula/articles/jumpstart-30-create-azure-cloud-service-package-cspkg-of-visual-studio-2013-project-solution-using-powershell/