gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-30 18:43:39 25 4
gpt4 key购买 nike

我在 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”文件。但是我已经验证了这个文件在第一次构建之后确实存在,而且我不相信它会被删除并重新创建(但我愿意接受有关如何验证这一点的建议)。我在进行第二次构建时尝试查看该文件夹,但我从未看到它消失。

另一个线索是此行为始于特定的 checkin ,其中开发人员向项目添加了两个文件: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".

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

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

最佳答案

好吧,我终于明白了。为后代张贴答案。

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

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

另外,有人告诉我这不会发生在 VS2010 中(虽然还没有测试过)。

关于c# - 每次在我的 VS 2008 解决方案中重建项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4091305/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com