我有简单的 .net core 2.0 应用程序和 Angular 2。 为了托管我的应用程序,我使用 Azure Web 服务,也是我在 GitHub 上发布的源代码。当我在 master 分支上进行一些更改时,它总是会自动部署在 Azure 上。
当我对 C# 代码进行更改时,它工作正常,但是当我对 Angular 2 + TS 编解码器进行任何更改时,我的代码无法成功部署。而且我不知道为什么!
我每次都会遇到同样的错误,例如 (无法找到并移动 main.84325e8f477352023e49.bundle.js 文件,因为它不存在)
但是当我转到 Azure 仪表板并再次单击“重新部署”时,它工作正常。
我使用 Angular-CLI 来构建 Angular 2 应用程序。 另外,我已将 *.csproj 文件更改为在构建 .net core 应用程序之前执行一些 Angular-CLI 命令。
<Target Name="Build Angular" BeforeTargets="Build" Condition="'$(Configuration)' == 'Release'">
<Message Text="* * * * * * NPM * * * * * *" Importance="high" />
<Exec Command="npm install" />
<Message Text="* * * * * * Building Angular App * * * * * *" Importance="high" />
<Exec Command="npm run build" />
</Target>
npm run build: - 这是使用 AOT 进程构建 Angular 应用程序的默认 Angular-CLI 命令 ng build --prod
当人们使用Visual Studio Team Services并为其创建Azure部署过程时,我发现了很多文章,但我无法使用它。我需要使用 GitHub 上的唯一部署。
此外,部署需要很长时间,例如 15-20 分钟。这很奇怪,因为本地速度要快得多,大约 1-2 分钟。
有什么想法,如何改进部署过程并通过 GitHub 上的 master 分支的自动部署来解决此问题。
最佳答案
根据你的描述,我自己制作了一个测试demo,效果很好。
我在 Visual Studio 中使用了 Net Core 2.0 Angular 模板。
然后我使用 git 将整个应用程序部署到 git 并在 azure web 应用程序中启用继续部署。
最后编辑ts文件并推送到github。
结果如下:
需要 521 秒:
我不更改 csporj 中的代码。所以我建议你可以尝试使用 vs net core Angular 模板来构建你的项目。
关于git - Angular 2 和 .net core 2.0 - Azure 上自动部署的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46776037/