运行 angular dotnet 发布后正式发布
Run angular production release after dotnet publish
我有一个 ASP.NET Core 2.0 应用程序,Angular 5 SPA 托管在同一文件夹中。
目前要部署到 IIS,我执行以下操作:
// First publish the release configuration
dotnet publish -c release
// Now delete the wwwroot directory as it is pulished with ng build
rm -r bin/release/netcoreapp2.0/publish/wwwroot
// Build the prod version of the angular app
ng build --prod
// copy the new wwwroot folder into the publish folder
cp -R wwwroot bin/release/netcoreapp2.0/publish/
这很令人困惑...我如何告诉 dotnet 发布到 运行 ng build --prod?
我尝试将以下内容添加到我的项目 csproj 文件中:
<Target Name="AngularBuild" AfterTargets="Publish">
<Exec Command="npm run build --prod" />
</Target>
您可以使用任何任务运行程序或自定义脚本来将所有这些命令一起调用。
例如,您可以在 package.json
中定义自定义 npm 脚本:
{
...
"scripts": {
"apppublish": "dotnet publish -c release && npm run build --prod",
...
}
}
然后在您需要发布应用程序时调用 npm run apppublish
。
在 .csproj 中
<Target Name="Build Angular" Condition="'$(Configuration)'=='Release'" BeforeTargets="Build">
<Message Text="* * * * * * Building Angular App * * * * * *" Importance="high"/>
<Exec Command="npm run build"/>
</Target>
然后在package.json
"scripts": {
"build": "npm run build --prod"
}
我有一个 ASP.NET Core 2.0 应用程序,Angular 5 SPA 托管在同一文件夹中。
目前要部署到 IIS,我执行以下操作:
// First publish the release configuration
dotnet publish -c release
// Now delete the wwwroot directory as it is pulished with ng build
rm -r bin/release/netcoreapp2.0/publish/wwwroot
// Build the prod version of the angular app
ng build --prod
// copy the new wwwroot folder into the publish folder
cp -R wwwroot bin/release/netcoreapp2.0/publish/
这很令人困惑...我如何告诉 dotnet 发布到 运行 ng build --prod?
我尝试将以下内容添加到我的项目 csproj 文件中:
<Target Name="AngularBuild" AfterTargets="Publish">
<Exec Command="npm run build --prod" />
</Target>
您可以使用任何任务运行程序或自定义脚本来将所有这些命令一起调用。
例如,您可以在 package.json
中定义自定义 npm 脚本:
{
...
"scripts": {
"apppublish": "dotnet publish -c release && npm run build --prod",
...
}
}
然后在您需要发布应用程序时调用 npm run apppublish
。
在 .csproj 中
<Target Name="Build Angular" Condition="'$(Configuration)'=='Release'" BeforeTargets="Build">
<Message Text="* * * * * * Building Angular App * * * * * *" Importance="high"/>
<Exec Command="npm run build"/>
</Target>
然后在package.json
"scripts": {
"build": "npm run build --prod"
}