引用本机dll的C#7.0 MSbuild未知生成错误



我有一个.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/projmy_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:cygwinhomeXXXXprojmy_project.csproj" on node 1 (default targets).
C:WINDOWSMicrosoft.NETFrameworkv4.0.30319Microsoft.WinFx.targets(268,9): error MC1000: Unknown build error,
'Could not load file or assembly 'file:///c:cygwinhomeXXXXprojnative32or64bit.dll' or one of its dependencies.
The module was expected to contain an assembly manifest.'  [c:cygwinhomeXXXXprojmy_project.csproj]
Done Building Project "c:cygwinhomeXXXXprojmy_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:cygwinhomeXXXXproj'.
Analysis Result : 'All'.
Recompiled XAML file : 'c:cygwinhomeXXXXprojmy_view.xaml'.
// other XAML files.....
Started the markup compilation.
OutputType is 'library'.
Input: Assembly Reference file: 'c:cygwinhomeXXXXprojmy_util.dll'.
Input: Assembly Reference file: 'c:XXXX.NETFrameworkv4.5mscorlib.dll'.
Input: Assembly Reference file: 'c:cygwinhomeXXXXprojNewtonsoft.Json.11.0.2libnet45Newtonsoft.Json.dll'.
Input: Assembly Reference file: 'c:XXXX.NETFrameworkv4.5PresentationCore.dll'.
Input: Assembly Reference file: 'c:XXXX.NETFrameworkv4.5PresentationFramework.dll'.
Input: Assembly Reference file: 'c:XXXX.NETFrameworkv4.5System.Configuration.dll'.
Input: Assembly Reference file: 'C:WINDOWSMicrosoft.NetassemblyGAC_MSILSystem.Runtimev4.0_4.0.0.0__b03f5f7f11d50a3aSystem.Runtime.dll'.
// other managed dll dependencies
......
Input: Assembly Reference file: 'c:cygwinhomeXXXXprojnative32.dll'.
Input: Assembly Reference file: 'c:cygwinhomeXXXXprojnative64.dll'.
C:WINDOWSMicrosoft.NETFrameworkv4.0.30319Microsoft.WinFx.targets(268,9): error MC1000: Unknown build error,

因此,出于某种原因,C#7.0编译器决定将构建目录中的所有dll作为依赖项,即使是.csproj文件中未引用的dll。

我真的很感激你能给我的任何指导,这已经折磨了我一段时间了,每次都做一次干净的打扮开始让人讨厌了。

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

我不知道这个项目的真正含义或作用,但它有一个很长的名字和不想要的副作用。如果有人能评论一下这意味着什么,我将不胜感激。

最新更新