我的VS 2008解决方案中的项目每次都需要重新构建

3
我在VS 2008中有一个C#项目,每次构建解决方案时都会重新构建,即使该项目及其依赖项都没有更改。这是一个很大的问题,因为解决方案非常庞大(>100个项目),而该项目在依赖链中非常低,因此现在导致大部分其他项目也需要重新构建,尽管不应该进行任何重建。(我正在执行“构建解决方案”,而不是“重新构建解决方案”)。
我知道这个项目是罪魁祸首,因为我将“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\Debug\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".

看起来还有一些其他的临时文件,但我不确定它们为什么会被生成,或者为什么被视为项目的输入。

非常感谢迄今为止的帮助!

1个回答

0

好了,我终于搞明白了。为了后人,我在这里发布答案。

在“解决方案资源管理器”中,我双击导致此问题的.edmx文件以打开“模型浏览器”。在“模型浏览器”中,我选择了我的模型,并在“属性”窗口中将“元数据工件处理”更改为“复制到输出目录”。

之后,它就可以正常工作了(不需要不必要的重建)!此外,有人告诉我,在VS2010中不会发生这种情况(尽管我没有测试过)。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接