[英]How to configure NCrunch so that it can build a Blazor project
When NCrunch (version 4.2.0.7) tries to build a Blazor project (version 3.0.0-preview9), it produces the following error:当 NCrunch(版本 4.2.0.7)尝试构建 Blazor 项目(版本 3.0.0-preview9)时,会产生以下错误:
packages\\microsoft.aspnetcore.blazor.build\\3.0.0-preview9.19465.2\\targets\\Blazor.MonoRuntime.targets (441, 5): The command "dotnet "C:\\Users\\Rodolfo.nuget\\packages\\microsoft.aspnetcore.blazor.mono\\3.0.0-preview9.19462.2\\build\\netstandard1.0../../tools/illink/illink.dll" -l none --disable-opt unreachablebodies --verbose --strip-security true --exclude-feature com --exclude-feature sre -v false -c link -u link -b true -d (... lots of files here...) exited with code -532462766.
包\\microsoft.aspnetcore.blazor.build\\3.0.0-preview9.19465.2\\targets\\Blazor.MonoRuntime.targets (441, 5):命令“dotnet”C:\\Users\\Rodolfo.nuget\\packages\\microsoft.aspnetcore .blazor.mono\\3.0.0-preview9.19462.2\\build\\netstandard1.0../../tools/illink/illink.dll" -l none --disable-opt unreachablebodies --verbose --strip-security true --exclude-feature com --exclude-feature sre -v false -c link -u link -b true -d (...这里有很多文件...)退出,代码为 -532462766。
How can I get NCrunch to build Blazor projects?如何让 NCrunch 构建 Blazor 项目?
Disclaimer: I'm writing this question after not finding a single answer online, including SO.免责声明:我在网上没有找到一个答案后写这个问题,包括 SO。 I have already found the solution and intend to answer the question myself in order to - hopefully - help someone else.
我已经找到了解决方案,并打算自己回答这个问题,以便 - 希望 - 帮助其他人。
TL;DR TL; 博士
Full explanation ... in case the details change.完整的解释......以防细节发生变化。
In line 441 of the .targets file mentioned in the error message you will find the Exec command that causes the error:在错误消息中提到的 .targets 文件的第 441 行中,您将找到导致错误的 Exec 命令:
<Exec Command="dotnet "$(MonoLinkerPath)" $(_BlazorLinkerAdditionalOptions) @(_BlazorFolderLookupPaths, ' ') -o "$(BlazorIntermediateLinkerOutputPath)" @(_BlazorAssemblyDescriptorFiles, ' ') @(_BlazorAssembliesToLink, ' ')" />
This command is wrapped in the following target:此命令包含在以下目标中:
<Target
Name="_LinkBlazorApplication"
Condition="$(_BlazorShouldLinkApplicationAssemblies) != ''"
Inputs="$(BlazorBuildLinkerInputsCache);
@(IntermediateAssembly);
@(_BlazorDependencyInput);
@(BlazorLinkerDescriptor)"
Outputs="$(BlazorIntermediateLinkerResultFilePath)"
>
Which means the Exec will only be executed if the _BlazorShouldLinkApplicationAssemblies property is not empty.这意味着只有在 _BlazorShouldLinkApplicationAssemblies 属性不为空时才会执行 Exec。 Searching the .targets file for where this internal property is set, you will find this PropertyGroup (line 152):
在 .targets 文件中搜索设置此内部属性的位置,您将找到此 PropertyGroup(第 152 行):
<PropertyGroup Label="Build properties">
<_BlazorShouldLinkApplicationAssemblies Condition="$(BlazorLinkOnBuild) == 'false'"></_BlazorShouldLinkApplicationAssemblies>
<_BlazorShouldLinkApplicationAssemblies Condition="$(BlazorLinkOnBuild) == 'true'">true</_BlazorShouldLinkApplicationAssemblies>
<_BlazorBuiltInBclLinkerDescriptor>$(MSBuildThisFileDirectory)BuiltInBclLinkerDescriptor.xml</_BlazorBuiltInBclLinkerDescriptor>
</PropertyGroup>
This is why setting the BlazorLinkOnBuild (as of 3.2.0-preview3, renamed to BlazorWebAssemblyEnableLinking ) to false allows NCrunch to build the project.这就是将BlazorLinkOnBuild (从 3.2.0-preview3 开始,重命名为BlazorWebAssemblyEnableLinking )设置为false允许 NCrunch 构建项目的原因。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.