【发布时间】:2018-04-09 09:13:34
【问题描述】:
我有一个带有 React 前端的 ASP.NET Core 解决方案。我现在遇到一个问题,我无法使用 Visual Studio 中的正常发布窗口发布代码。我发布到 Azure Web 应用程序中的一个 Web 应用程序,它非常适用于我以相同方式构建的所有其他解决方案。
代码在本地完美运行,我可以在本地运行npm install 没有问题。
该错误显然来自发布时未找到的某些文件。在我的项目文件中,我一直在调试,发现这是挑战:
<Target Name="PublishRunWebpack" AfterTargets="ComputeFilesToPublish">
<!-- As part of publishing, ensure the JS resources are freshly built in production mode -->
<Exec Command="npm install" />
<Exec Command="node node_modules/webpack/bin/webpack.js --config webpack.config.vendor.js --env.prod" />
<Exec Command="node node_modules/webpack/bin/webpack.js --env.prod" />
<!-- Include the newly-built files in the publish output -->
<ItemGroup>
<DistFiles Include="wwwroot\dist\**" />
<ResolvedFileToPublish Include="@(DistFiles->'%(FullPath)')" Exclude="@(ResolvedFileToPublish)">
<RelativePath>%(DistFiles.Identity)</RelativePath>
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</ResolvedFileToPublish>
</ItemGroup>
</Target>
Visual Studio 中的错误:
Severity Code Description Project File Line Suppression State
Error The command "npm install" exited with code 9009. Likvido.CreditRisk C:\Users\MYNAME\Documents\Github\Likvido.CreditRisk\Likvido.CreditRisk\Likvido.CreditRisk\Likvido.CreditRisk.csproj 75
如果我注释掉前三行(npm install 和两个 webpack),我可以发布解决方案,但显然无法使用 JavaScript。
知道如何解决这个问题吗?至少,如何更好地调试它?
Visual Studio 中的视觉错误:
GUI中引用的日志文件:
09/04/2018 11.07.03
System.AggregateException: One or more errors occurred. ---> System.Exception: Publish failed due to build errors. Check the error list for more details.
--- End of inner exception stack trace ---
at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
at Microsoft.VisualStudio.Web.Publish.PublishService.VsWebProjectPublish.<>c__DisplayClass40_0.<PublishAsync>b__2()
at System.Threading.Tasks.Task`1.InnerInvoke()
at System.Threading.Tasks.Task.Execute()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.VisualStudio.ApplicationCapabilities.Publish.ViewModel.ProfileSelectorViewModel.<RunPublishTaskAsync>d__88.MoveNext()
---> (Inner Exception #0) System.Exception: Publish failed due to build errors. Check the error list for more details.<---
===================
【问题讨论】:
标签: asp.net asp.net-core asp.net-core-mvc asp.net-core-2.0 npm-install