Azure Pipeline项目具有两个Build Agents
成功构建,并将资产,chunk.js文件和bundle.js文件发布为工件
我从以前的构建代理下载工件,并将其提取到$(build.stagingDirectory)/ Scripts / dist目录中,因为它们将由ASP.net项目使用。
我的提取文件任务ymal为
1 2 3 4 5 6 | steps: - task: ExtractFiles@1 displayName: 'Extract files bundle.zip' inputs: archiveFilePatterns: '$(Pipeline.Workspace)/dist/$(Build.BuildId)_bundle.zip' destinationFolder: '$(build.sourcesDirectory)/Scripts/dist' |
MSBuild构建ASP.net项目时,无法找到
MS Build yaml是:
1 2 3 4 5 6 7 8 9 10 11 | steps: - task: MSBuild@1 displayName: 'Build solution NMG.Portal.MVCForAngular' inputs: solution: NMG.WebApp.MVCForAngular/NMG.WebApp.MVCForAngular.csproj msbuildArguments: '/p:ProjectFile=$(build.sourcesDirectory)\ MG.WebApp.MVCForAngular\ MG.WebApp.MVCForAngular.csproj /p:DeployOnBuild=true /p:SkipInvalidConfigurations=true /p:OutDir="$(build.stagingDirectory)\"' clean: false logProjectEvents: true createLogFile: true |
我的ASP.NET BundleConfig.cs文件具有以下代码。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | public class BundleConfig { // For more information on bundling, visit http://go.microsoft.com/fwlink/?LinkId=301862 public static void RegisterBundles(BundleCollection bundles) { bundles.Add(new ScriptBundle("~/bundles/jquery").Include( "~/Scripts/jquery-{version}.js")); // Use the development version of Modernizr to develop with and learn from. Then, when you're // ready for production, use the build tool at http://modernizr.com to pick only the tests you need. bundles.Add(new ScriptBundle("~/bundles/modernizr").Include( "~/Scripts/modernizr-*")); bundles.Add(new ScriptBundle("~/bundles/bootstrap").Include( "~/Scripts/bootstrap.js", "~/Scripts/respond.js")); bundles.Add(new StyleBundle("~/Content/css").Include( "~/Content/bootstrap.css", "~/Content/site.css")); bundles.Add(new ScriptBundle("~/bundles/nmg").Include( "~/Scripts/dist/inline*", "~/Scripts/dist/polyfills*", "~/Scripts/dist/scripts*", "~/Scripts/dist/vendor*", "~/Scripts/dist/main*")); bundles.Add(new StyleBundle("~/Content/nmg").Include( "~/Scripts/dist/styles*")); } } |
从逻辑上讲这应该起作用。
我想知道这里缺少什么?为什么MSBuild无法找到我在Scripts / dist中提取的捆绑软件。
复制到Scripts / dist文件夹的main.bundle.js是main.7515c53aa0f2ef625908.bundle.js,但MSBuild不会考虑。
实际的问题是,当MSBuild创建发布文件时,它会根据构建定义复制文件。我将.csproj文件编辑为以下文件,该文件复制了相关文件。
1 2 3 4 | <Content Include="assets\\i18n\\**" /> <Content Include="Scripts\\dist\\*.bundle.js" /> <Content Include="Scripts\\dist\\*.bundle.css" /> <Content Include="*.chunk.js" /> |
之所以可行,是因为在进行MSBuild任务之前,我确实将angular文件复制到了相关的文件夹中。
同意Thangadurai,这可能是与路径相关的问题。
检查
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | `$(build.sourcesDirectory)`(sln directory) | Scripts | | | ----dist | | | ----main.xxx.bundle.js | xx.sln | NMG.WebApp.MVCForAngular | NMG.WebApp.MVCForAngular.csproj | Scripts |
提取的main.xx.js放在解决方案目录中的Script文件夹中,但是,当
此外:我建议您检查
Msbuild不会将