繁体   English   中英

C# 7.0 MSbuild 引用本机的未知构建错误 dll

[英]C# 7.0 MSbuild unknown build error referencing native dll

我有一个通过调用 msbuild 从控制台构建的 .net4.5 项目。现在,构建目录可以包含(如果不进行干净构建)额外的本机 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 文件中引用的。

我真的很感激你能给我任何指导,这已经困扰我一段时间了,每次都做一个干净的制作开始令人讨厌。

感谢@PauloMorgado 建议使用 msbuildlog,我能够确定 dll 被ImplicitlyExpandDesignTimeFacades项引用,并在我的项目文件中添加<ImplicitlyExpandDesignTimeFacades>false</ImplicitlyExpandDesignTimeFacades>似乎解决了这个问题。

我不知道这个项目的真正含义或作用,但它有一个很长的名字和不良副作用。 如果有人可以评论它的含义,将不胜感激。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM