2010-11-03 86 views
3

我在VS 2008中有一個C#項目,每次構建解決方案時都會重建該項目,即使此項目中的任何內容或其任何依賴項都未更改。這造成了一個巨大的問題,因爲解決方案非常大(> 100個項目),而且這個項目在依賴關係鏈上非常低,所以現在大多數其他項目也會重建,因爲沒有重建應該有是必要的。 (我在做「構建解決方案」而不是「重建解決方案」。)我的VS 2008解決方案中的項目每次重建

我知道這個項目是罪魁禍首,因爲我將「MSBuild項目構建輸出冗長」轉變爲「診斷」。然後我構建解決方案兩次,而不更改構建之間的任何內容。在第二個版本中,這是正在重建的解決方案中的第一個項目,正如注意到Csc.exe正在執行一樣。

下面是我在生成輸出看到:

------ Build started: Project: COS.BusinessEntities, Configuration: Debug Any CPU ------ 

... 

Target "CoreCompile" in file "c:\WINDOWS\Microsoft.NET\Framework\v3.5\Microsoft.CSharp.targets": 
Building target "CoreCompile" completely. 
Output file "bin\Debug\COS.BusinessEntities.XML" does not exist. 
Task "Csc" 
    Command: 
    c:\WINDOWS\Microsoft.NET\Framework\v3.5\Csc.exe /noconfig /nowarn:1591,1573,0219,0168,1572,1587,1570,1701,1702 /errorreport:prompt /warn:4 /doc:bin\Debug\COS.BusinessEntities.XML /define:DEBUG;TRACE ... 

這樣看來,當它到達COS.BusinessEntities項目,它沒有找到的「bin \調試\ COS.BusinessEntities.XML 「文件。但是我已經證實這個文件確實存在於第一次構建之後,並且我不相信它會被刪除並重新創建(但對於如何驗證這一點可以提供建議)。我在嘗試第二次構建時嘗試觀看文件夾,但從未看到它消失。

另一個線索是,這種行爲開始於特定的簽入,其中開發人員向項目添加了兩個文件:一個OptionsEntities.edmx文件和OptionsEntities.Designer.cs。下面也被加入到了COS.BusinessEntities.prj文件:

<Compile Include="Options\Entities\OptionsEntities.Designer.cs"> 
    <AutoGen>True</AutoGen> 
    <DesignTime>True</DesignTime> 
    <DependentUpon>OptionsEntities.edmx</DependentUpon> 
    </Compile> 

    ... 

    <EntityDeploy Include="Options\Entities\OptionsEntities.edmx"> 
    <Generator>EntityModelCodeGenerator</Generator> 
    <LastGenOutput>OptionsEntities.Designer.cs</LastGenOutput> 
    </EntityDeploy> 

顯然,這些項目是必要的EDMX文件,但我想知道如果某些值不正確,導致出現此問題。我確信這是罪魁禍首,就像我得到以前的變更集一樣,這個問題就會消失;在沒有代碼更改之後構建解決方案時,項目不會自行重建。

任何幫助表示讚賞!我幾天來一直在絞盡腦汁!

感謝,

克里斯

編輯: 去除該項目的XML文檔的XML文件後,我仍然得到了同樣的問題,但這裏的新的輸出:

Target "CoreCompile" in file "c:\WINDOWS\Microsoft.NET\Framework\v3.5\Microsoft.CSharp.targets": 
    Building target "CoreCompile" completely. 
    Input file "C:\Documents and Settings\<my username>\Local Settings\Temp\tmp6D36.tmp" is newer than output file "obj\Debug\COS.BusinessEntities.pdb". 
    Task "Csc" 
    Command: 
    c:\WINDOWS\Microsoft.NET\Framework\v3.5\Csc.exe /noconfig /nowarn:1591,1573,0219,0168,1572,1587,1570,1701,1702 /errorreport:prompt /warn:4 /define:DEBUG;TRACE ... 

...那個臨時文件每次都不一樣!哎呀!現在要做什麼?

編輯2: 以下是編譯輸出的相關部分,與此相關的臨時文件(這些開始BusinessEntities項目內):

Target "SplitResourcesByCulture" in file "c:\WINDOWS\Microsoft.NET\Framework\v3.5\Microsoft.Common.targets": 
    Task "Warning" skipped, due to false condition; ('@(ResxWithNoCulture)'!='') was evaluated as (''!=''). 
    Task "Warning" skipped, due to false condition; ('@(ResxWithCulture)'!='') was evaluated as (''!=''). 
    Task "Warning" skipped, due to false condition; ('@(NonResxWithCulture)'!='') was evaluated as (''!=''). 
    Task "Warning" skipped, due to false condition; ('@(NonResxWithNoCulture)'!='') was evaluated as (''!=''). 
    Task "AssignCulture" 
    Culture of "" was assigned to file "C:\Documents and Settings\<my username>\Local Settings\Temp\tmp6D36.tmp". 
    Culture of "" was assigned to file "C:\Documents and Settings\<my username>\Local Settings\Temp\tmp6D38.tmp". 
    Culture of "" was assigned to file "C:\Documents and Settings\<my username>\Local Settings\Temp\tmp6D37.tmp". 
    Done executing task "AssignCulture". 
Done building target "SplitResourcesByCulture" in project "COS.BusinessEntities.csproj". 
Target "CreateManifestResourceNames" in file "c:\WINDOWS\Microsoft.NET\Framework\v3.5\Microsoft.CSharp.targets": 
    Task "CreateCSharpManifestResourceName" 
    Root namespace is 'COS.BusinessEntities'. 
    Resource file 'C:\Documents and Settings\<my username>\Local Settings\Temp\tmp6D36.tmp' doesn't depend on any other file. 
    Resource file 'C:\Documents and Settings\<my username>\Local Settings\Temp\tmp6D36.tmp' gets manifest resource name 'COS.BusinessEntities.tmp6D36.tmp'. 
    Resource file 'C:\Documents and Settings\<my username>\Local Settings\Temp\tmp6D38.tmp' doesn't depend on any other file. 
    Resource file 'C:\Documents and Settings\<my username>\Local Settings\Temp\tmp6D38.tmp' gets manifest resource name 'COS.BusinessEntities.tmp6D38.tmp'. 
    Resource file 'C:\Documents and Settings\<my username>\Local Settings\Temp\tmp6D37.tmp' doesn't depend on any other file. 
    Resource file 'C:\Documents and Settings\<my username>\Local Settings\Temp\tmp6D37.tmp' gets manifest resource name 'COS.BusinessEntities.tmp6D37.tmp'. 
    Done executing task "CreateCSharpManifestResourceName". 
    Task "CreateCSharpManifestResourceName" skipped, due to false condition; ('%(EmbeddedResource.ManifestResourceName)' == '' and '%(EmbeddedResource.WithCulture)' == 'true' and '%(EmbeddedResource.Type)' == 'Non-Resx') was evaluated as ('' == '' and 'false' == 'true' and 'Non-Resx' == 'Non-Resx'). 
Done building target "CreateManifestResourceNames" in project "COS.BusinessEntities.csproj". 

再稍加進一步下跌:

Target "_GenerateCompileInputs" in file "c:\WINDOWS\Microsoft.NET\Framework\v3.5\Microsoft.Common.targets": 
    Task "Warning" skipped, due to false condition; ('@(ManifestResourceWithNoCulture)'!='' and '%(ManifestResourceWithNoCulture.EmittedForCompatibilityOnly)'=='') was evaluated as (''!='' and ''==''). 
    Task "Warning" skipped, due to false condition; ('@(ManifestNonResxWithNoCultureOnDisk)'!='' and '%(ManifestNonResxWithNoCultureOnDisk.EmittedForCompatibilityOnly)'=='') was evaluated as ('C:\Documents and Settings\<my username>\Local Settings\Temp\tmp6D36.tmp;C:\Documents and Settings\<my username>\Local Settings\Temp\tmp6D38.tmp;C:\Documents and Settings\<my username>\Local Settings\Temp\tmp6D37.tmp'!='' and 'true'==''). 
Done building target "_GenerateCompileInputs" in project "COS.BusinessEntities.csproj". 

所以它看起來還有其他一些臨時文件,但我不確定它們爲什麼會生成,或者它們爲什麼被視爲項目的輸入。

非常感謝迄今爲止的幫助!

回答

0

嗯,我終於明白了。爲後代發佈答案。

在解決方案資源管理器中,我雙擊導致打開模型瀏覽器的.edmx文件。在模型瀏覽器中,我選擇了我的模型,並在「屬性」窗口中將「元數據工件處理」更改爲「複製到輸出目錄」。

之後,它工作正常(沒有不必要的重建)!

此外,我被告知,這不會發生在VS2010(雖然沒有測試過)。

相關問題