2009-04-27 143 views
1

我只是創建一個包含3個項目的解決方案。Visual Studio 2008在發佈後事件之後會發生什麼事件?

排序生成順序

  1. 包含在/ ASP.NET的ClientBin的Web應用程序項目

  2. Windows窗體應用程序用來優化所有Silverlight應用程序當Visual Studio傳遞構建(構建後事件)時,xap在/ ClientBin中。

  3. ASP.NET Web應用程序是顯示Silverlight應用程序中/的ClientBin

當我構建ASP.NET Web應用程序的成功,在Web應用程序項目的ClientBin目錄中包含3個XAP文件。之後,VS.net會觸發執行Windows窗體應用程序的構建後命令事件。 Windows窗體優化3個Xap文件中的所有Xap和遠程2 Xap文件。

最後,Vs.net再次將Silverlight應用程序項目中的3個Xap文件複製到ClientBin目錄。爲什麼?我找不到任何有關日誌生成後事件後複製XAP文件(通過使用MSBuild項目建設輸出詳細程度:診斷)

Target "PostBuildEvent" in file "C:\Windows\Microsoft.NET\Framework\v3.5\Microsoft.Common.targets": 
    Task "Exec" 
    Command: 
    **T:\myProject\Higgs\Higgs\Higgs.Utils.WinApp\bin\Higgs.Utils.WinApp.exe mode=OptimizeXap clientbindir=T:\myProject\Higgs\Higgs\Higgs.Web.UI\ClientBin\ mainxapfilename=Higgs.Silverlight.UI** 
    Done executing task "Exec". 
Done building target "PostBuildEvent" in project "Higgs.Web.UI.csproj". 
Target "CoreBuild" in file "C:\Windows\Microsoft.NET\Framework\v3.5\Microsoft.Common.targets": 
    Task "CallTarget" skipped, due to false condition; ('$(UnloadProjectsOnCompletion)'=='true') was evaluated as ('false'=='true'). 
    Task "CallTarget" skipped, due to false condition; ('$(UnloadProjectsOnCompletion)'=='true') was evaluated as ('false'=='true'). 
    Task "CallTarget" skipped, due to false condition; ('$(UnloadProjectsOnCompletion)'=='true') was evaluated as ('false'=='true'). 
Done building target "CoreBuild" in project "Higgs.Web.UI.csproj". 
Target "AfterBuild" in file "C:\Windows\Microsoft.NET\Framework\v3.5\Microsoft.Common.targets": 
Done building target "AfterBuild" in project "Higgs.Web.UI.csproj". 
Target "Build" in file "C:\Windows\Microsoft.NET\Framework\v3.5\Microsoft.Common.targets": 
    Building target "Build" completely. 
    No input files were specified. 
Done building target "Build" in project "Higgs.Web.UI.csproj". 
Target "AfterRebuild" in file "C:\Windows\Microsoft.NET\Framework\v3.5\Microsoft.Common.targets": 
Done building target "AfterRebuild" in project "Higgs.Web.UI.csproj". 
Target "Rebuild" in file "C:\Windows\Microsoft.NET\Framework\v3.5\Microsoft.Common.targets": 
    Building target "Rebuild" completely. 
    No input files were specified. 
Done building target "Rebuild" in project "Higgs.Web.UI.csproj". 

Done building project "Higgs.Web.UI.csproj". 

更新

我通過建立在Windows更新的構建順序表單申請。構建Web應用程序之後。接下來,我使用Windows Dorm應用程序構建後事件來執行其EXE。一切正常。但我不喜歡這個解決方案,因爲這對我來說是非常奇怪的解決方案。

回答

0

我假設項目互相引用?所以:

  • ASP.NET Web App至少引用了SilverLight應用程序。
  • Win Forms App引用了Silverlight應用程序。

除非您不告訴它,否則Visual Studio會自動將相關文件複製到項目層次結構中。因此Visual Studio將採取的步驟是:

  1. 構建Silverlight應用程序,並將其輸出複製到窗體應用程序和Web應用程序
  2. 運行任何職位建設中的「生成」選項卡中定義的Silverlight應用程序項目事件。
  3. 構建Win Forms App,如果它被別的東西引用,則適當地複製輸出。
  4. 運行Win Forms App項目的「構建」選項卡中定義的任何構建事件。
  5. 構建Web應用程序
  6. 運行Web App項目的「構建」選項卡中定義的任何構建事件。
  7. 運行通過MSBuild定義的任何「構建後」事件。

基本上大部分依賴移動的發生之前後生成事件:

Task "FindUnderPath" 
    Comparison path is "D:\Projects\PublicSites\WebTest". 
    Path [...] 
    [...] 
Done executing task "FindUnderPath". 
Task "FindUnderPath" 
    Comparison path is "bin\". 
    Path [...] 
    [...] 
Done executing task "FindUnderPath". 
Task "FindUnderPath" 
    Comparison path is "obj\Debug\". 
    Path [...] 
    [...] 
Done executing task "FindUnderPath". 
Task "RemoveDuplicates" 
Done executing task "RemoveDuplicates". 
Done building target "_CleanGetCurrentAndPriorFileWrites" in project 
    "WebTest.csproj". 
Target "IncrementalClean" in file 
    "c:\WINDOWS\Microsoft.NET\Framework\v3.5\Microsoft.Common.targets": 
Task "FindUnderPath" 
    Comparison path is "bin\". 
Done executing task "FindUnderPath". 
Task "FindUnderPath" 
    Comparison path is "obj\Debug\". 
Done executing task "FindUnderPath". 
Task "Delete" 
Done executing task "Delete". 
Task "RemoveDuplicates" 
Done executing task "RemoveDuplicates". 
Task "WriteLinesToFile" 
Done executing task "WriteLinesToFile". 
Done building target "IncrementalClean" in project 
    "WebTest.csproj". 

然後構建和AfterBuild事件發生。

我的猜測是,VS注意到SilverLight應用程序的輸出與它下面的版本不同,因此會提取新副本。

+0

是的!我想是這樣。如何禁用將新副本提取到ClientBin目錄? – 2009-05-01 09:05:18

0

這並不能解決您的情況,但僅供參考,PostBuildEvent看起來像是構建過程中的最後一步;您可以通過檢查

Ç詳細瞭解訂購:\ WINDOWS \ Microsoft.NET \框架\ V2.0.50727 \ Microsoft.Common.targets

足見其的MSBuild邏輯。

+0

但我認爲所有的Silverlight應用程序項目都在web應用程序項目構建完成後將所有xap複製到clientbin。我不知道爲什麼。這很奇怪。 PS:我試圖在生成後事件完成之前通過7-Zip打開xap文件(用於鎖定文件)。但是我在VS.net的控制檯中找不到任何錯誤消息。 – 2009-04-28 03:25:03

0

我不知道你到底是什麼問題,但是如果你的項目有任何依賴性,你應該命令它們正確地構建。