【发布时间】:2020-07-28 18:38:14
【问题描述】:
我有一个 .net4.5 项目,它是通过调用 msbuild 从控制台构建的。 现在,构建目录可以包含(如果不进行干净构建)额外的本机 32 位和 64 位 dll 文件。
到目前为止,该项目是使用 C# 5.0 (VS2013) 编译的,没有任何问题。 我最近将项目切换为使用 C# 7.0 (VS2017) 编译,并在构建目录包含本机 dll(XXXX - 编辑路径)时开始收到错误:
Error: Command: "/cygdrive/C/XXX/4.0/15.0/Bin/MSBuild.exe c:/cygwin/home/XXXX/proj\my_project.csproj
/p:SignAssembly=true /p:AssemblyOriginatorKeyFile=c:/XXXX/my_project.snk
/p:FrameworkPathOverride=c:/XXXX/.NETFramework/v4.5"
Microsoft (R) Build Engine version 15.5.180.51428 for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.
Build started 28-Jul-20 20:54:25.
Project "c:\cygwin\home\XXXX\proj\my_project.csproj" on node 1 (default targets).
C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Microsoft.WinFx.targets(268,9): error MC1000: Unknown build error,
'Could not load file or assembly 'file:///c:\cygwin\home\XXXX\proj\native32or64bit.dll' or one of its dependencies.
The module was expected to contain an assembly manifest.' [c:\cygwin\home\XXXX\proj\my_project.csproj]
Done Building Project "c:\cygwin\home\XXXX\proj\my_project.csproj" (default targets) -- FAILED.
当使用/v:d 运行 msbuild 时,我得到以下信息:
.....
Task "MarkupCompilePass1"
Microsoft (R) Build Task 'MarkupCompilePass1' Version '4.8.3761.0 built by: NET48REL1'.
Copyright (C) Microsoft Corporation 2005. All rights reserved.
Current project directory is 'c:\cygwin\home\XXXX\proj\'.
Analysis Result : 'All'.
Recompiled XAML file : 'c:\cygwin\home\XXXX\proj\my_view.xaml'.
// other XAML files.....
Started the markup compilation.
OutputType is 'library'.
Input: Assembly Reference file: 'c:\cygwin\home\XXXX\proj\my_util.dll'.
Input: Assembly Reference file: 'c:\XXXX\.NETFramework\v4.5\mscorlib.dll'.
Input: Assembly Reference file: 'c:\cygwin\home\XXXX\proj\Newtonsoft.Json.11.0.2\lib\net45\Newtonsoft.Json.dll'.
Input: Assembly Reference file: 'c:\XXXX\.NETFramework\v4.5\PresentationCore.dll'.
Input: Assembly Reference file: 'c:\XXXX\.NETFramework\v4.5\PresentationFramework.dll'.
Input: Assembly Reference file: 'c:\XXXX\.NETFramework\v4.5\System.Configuration.dll'.
Input: Assembly Reference file: 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Runtime\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Runtime.dll'.
// other managed dll dependencies
......
Input: Assembly Reference file: 'c:\cygwin\home\XXXX\proj\native32.dll'.
Input: Assembly Reference file: 'c:\cygwin\home\XXXX\proj\native64.dll'.
C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Microsoft.WinFx.targets(268,9): error MC1000: Unknown build error,
因此出于某种原因,C# 7.0 编译器决定将构建目录中的所有 dll 作为依赖项,即使是 .csproj 文件中未引用的那些。
我真的很感激你能给我的任何方向,这已经困扰我一段时间了,每次都做干净的事情开始很烦人。
【问题讨论】:
-
使用msbuildlog.com 了解为什么将这些 DLL 提供给编译器。