[英]MSBuild fails to build when compiling C# project referencing C++/CLI DLL in x86
[英]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.