我有一个非常类似于下面问题Visual Studio C# projects force a rebuild when switching from debug to release and vice-versa中描述的问题。
我有C#两个项目,一个项目引用另一个。如果我在Debug中构建(F6)而在Release中构建(F6)。如果我现在切换回Debug和build(F6)它应该是最新的。
事实就是如此。所以我可以看到在bin / Debug文件夹中,文件日期和程序集版本没有变化。
但是,如果我打开项目的XML文档文件,该项目在项目属性/构建/输出的项目属性/构建/输出下具有项目引用,那么每次我从Debug切换到Release或者反之亦然。
要重新创建问题:
File
/ New Project...
Visual C#
- > Console Application
。保持生成的代码不变。Add
- > New Project...
Visual C#
- > Class Library
。保持生成的代码不变。ConsoleApplication1
,然后选择Add Reference...
ClassLibrary1
/ Solution
/ Projects
下为OK
启用XML documentation file
两种配置(ConsoleApplication1
和Properties
)Build
配置中构建项目。它正如预期的那样构建。Output
配置并再次构建。它正如预期的那样构建。Debug
并再次构建。它构建,它不应该。它已经建好了,对吗?我们所做的就是更改目标配置选择。我得到以下构建输出:
Release
如果关闭Debug
,我将获得以下构建输出(它会跳过CoreCompile):
Release
这是一个错误吗?有解决方法吗?
当选择选项XML文档时,Visual Studio在从调试切换到发布时重建项目,反之亦然
是的,这是针对Visual Studio 2013和Visual Studio 2015的Debug
。除了额外的0.00001秒执行时间外,它只是一个微弱的震动,不会影响我们的构建结果。
此问题已在Visual Studio 2017版本15.6中得到修复。我已经在Visual Studio 2017 15.8.2(Current)中的最新版本上进行了测试,它按预期工作。
您可以在文件1>------ Build started: Project: ConsoleApplication1, Configuration: Debug Any CPU ------
1>Build started 07.09.2018 13:46:43.
1>GenerateTargetFrameworkMonikerAttribute:
1>Skipping target "GenerateTargetFrameworkMonikerAttribute" because all output files are up-to-date with respect to the input files.
1>CoreCompile:
1> C:\Program Files (x86)\MSBuild\12.0\bin\Csc.exe /noconfig /nowarn:1701,1702,2008 /nostdlib+ /platform:anycpu32bitpreferred /errorreport:prompt /warn:4 /doc:bin\Debug\ConsoleApplication1.XML /define:DEBUG;TRACE /errorendlocation /preferreduilang:en-US /highentropyva+ /reference:H:\CSharp\TestRebuild\ClassLibrary1\bin\Debug\ClassLibrary1.dll /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\Microsoft.CSharp.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\mscorlib.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Core.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Data.DataSetExtensions.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Data.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Xml.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Xml.Linq.dll" /debug+ /debug:full /filealign:512 /optimize- /out:obj\Debug\ConsoleApplication1.exe /subsystemversion:6.00 /target:exe /utf8output Program.cs Properties\AssemblyInfo.cs "C:\Users\WO\AppData\Local\Temp\.NETFramework,Version=v4.5.AssemblyAttributes.cs" obj\Debug\\TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs obj\Debug\\TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs obj\Debug\\TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs
1>_CopyAppConfigFile:
1>Skipping target "_CopyAppConfigFile" because all output files are up-to-date with respect to the input files.
1>CopyFilesToOutputDirectory:
1> Copying file from "obj\Debug\ConsoleApplication1.exe" to "bin\Debug\ConsoleApplication1.exe".
1> ConsoleApplication1 -> H:\CSharp\TestRebuild\ConsoleApplication1\bin\Debug\ConsoleApplication1.exe
1>
1>Build succeeded.
1>
1>Time Elapsed 00:00:00.41
========== Build: 1 succeeded, 0 failed, 1 up-to-date, 0 skipped ==========
中找到XML documentation file
添加到目标1>------ Build started: Project: ConsoleApplication1, Configuration: Debug Any CPU ------
1>Build started 07.09.2018 13:50:17.
1>GenerateTargetFrameworkMonikerAttribute:
1>Skipping target "GenerateTargetFrameworkMonikerAttribute" because all output files are up-to-date with respect to the input files.
1>CoreCompile:
1>Skipping target "CoreCompile" because all output files are up-to-date with respect to the input files.
1>_CopyAppConfigFile:
1>Skipping target "_CopyAppConfigFile" because all output files are up-to-date with respect to the input files.
1>CopyFilesToOutputDirectory:
1> ConsoleApplication1 -> H:\CSharp\TestRebuild\ConsoleApplication1\bin\Debug\ConsoleApplication1.exe
1>
1>Build succeeded.
1>
1>Time Elapsed 00:00:00.07
========== Build: 1 succeeded, 0 failed, 1 up-to-date, 0 skipped ==========
中的复制任务:
known issue
如果此错误影响您的工作,您可以将Visual Studio更新到2017年。
希望这可以帮助。