我的VS 2008解决方案中的项目每次都在重建

时间:2010-11-03 20:20:23

标签: c# visual-studio-2008 msbuild project

我在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 :(得分:0)

好吧,我终于明白了。为后代发布答案。

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

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

另外,我被告知在VS2010中不会发生这种情况(尽管没有测试过)。