【问题标题】:VSTS CI - Build of ASP.NET Core 1.1 failed - Microsoft.Build.Utilities.v4.0 not foundVSTS CI - 构建 ASP.NET Core 1.1 失败 - 找不到 Microsoft.Build.Utilities.v4.0
【发布时间】:2017-11-21 02:21:15
【问题描述】:

我为使用 Azure AD B2C 的 ASP.NET Core 1.1 项目设置了 CI(来自此示例 - https://github.com/Azure-Samples/active-directory-b2c-dotnetcore-webapp)。所以这就是我在 .csproj 文件中的内容:

<Project Sdk="Microsoft.NET.Sdk.Web">

  <PropertyGroup>
    <TargetFramework>netcoreapp1.1</TargetFramework>
    <MvcRazorCompileOnPublish>true</MvcRazorCompileOnPublish>
    <PreserveCompilationContext>true</PreserveCompilationContext>
  </PropertyGroup>

  <PropertyGroup>
    <PackageTargetFallback>$(PackageTargetFallback);portable-net45+win8+wp8+wpa81;</PackageTargetFallback>
  </PropertyGroup>

  <ItemGroup>
...
  </ItemGroup>
  <ItemGroup>
    <PackageReference Include="BuildWebCompiler" Version="1.11.326" />
    <PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.0.1" />
    <PackageReference Include="Microsoft.AspNetCore" Version="1.1.2" />
    <PackageReference Include="Microsoft.AspNetCore.Authentication.Cookies" Version="1.1.2" />
    <PackageReference Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="1.1.2" />
    <PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.1.3" />
    <PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.ViewCompilation" Version="1.1.1" />
    <PackageReference Include="Microsoft.AspNetCore.Rewrite" Version="1.0.2" />
    <PackageReference Include="Microsoft.AspNetCore.Session" Version="1.1.2" />
    <PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="1.1.2" />
    <PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="1.1.2" />
    <PackageReference Include="Microsoft.Identity.Client" Version="1.1.0-preview" />
    <PackageReference Include="Microsoft.VisualStudio.Web.BrowserLink" Version="1.1.2" />
  </ItemGroup>
  <ItemGroup>
    <DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="1.0.1" />
  </ItemGroup>

</Project>

当我转到 VSTS 时,我看到以下错误日志:


开始:构建

**************************************************** *************************************

任务:.NET Core 描述:使用 dotnet core 命令行构建、测试和发布。 版本:1.0.2 作者:微软公司

帮助: More Information

"C:\Program Files\dotnet\dotnet.exe" build d:\a\1\s\MMLServices\MMLServices.csproj --配置发布 Microsoft (R) Build Engine 版本 15.1.1012.6693 版权所有 (C) 微软公司。保留所有权利。

C:\Users\buildguest.nuget\packages\buildwebcompiler\1.11.326\build\BuildWebCompiler.targets(15,9):错误 MSB4062:无法从程序集 C 加载“WebCompiler.CompilerBuildTask”任务: \Users\buildguest.nuget\packages\buildwebcompiler\1.11.326\build..\tools\WebCompiler.exe。无法加载文件或程序集“Microsoft.Build.Utilities.v4.0,Version=4.0.0.0,Culture=neutral,PublicKeyToken=b03f5f7f11d50a3a”。该系统找不到指定的文件。确认声明正确,程序集及其所有依赖项都可用,并且任务包含实现 Microsoft.Build.Framework.ITask 的公共类。 [d:\a\1\s\MMLServices\MMLServices.csproj]

构建失败。

C:\Users\buildguest.nuget\packages\buildwebcompiler\1.11.326\build\BuildWebCompiler.targets(15,9):错误 MSB4062:无法从程序集 C 加载“WebCompiler.CompilerBuildTask”任务: \Users\buildguest.nuget\packages\buildwebcompiler\1.11.326\build..\tools\WebCompiler.exe。无法加载文件或程序集“Microsoft.Build.Utilities.v4.0,Version=4.0.0.0,Culture=neutral,PublicKeyToken=b03f5f7f11d50a3a”。该系统找不到指定的文件。确认声明正确,程序集及其所有依赖项都可用,并且任务包含实现 Microsoft.Build.Framework.ITask 的公共类。 [d:\a\1\s\MMLServices\MMLServices.csproj] 0 个警告 1 个错误

经过时间 00:00:03.66 错误:C:\Program Files\dotnet\dotnet.exe 失败,返回码:1 Dotnet 命令在以下项目中因非零退出代码而失败:d:\a\1\s\MMLServices\MMLServices.csproj

那么,我该如何解决这个问题?

更新:

我添加了debug=true,这是之后的日志(发布任务):

2017-06-20T15:23:36.6048010Z [command]"C:\Program Files\dotnet\dotnet.exe" 发布 d:\a\1\s\MMLServices\MMLServices.csproj --配置发布 --输出 d:\a\1\a\MMLServices 2017-06-20T15:23:36.7748032Z Microsoft (R) Build Engine 版本 15.1.1012.6693 2017-06-20T15:23:36.7758030Z 版权所有 (C) Microsoft Corporation。版权所有。 2017-06-20T15:23:36.7758030Z 2017-06-20T15:23:37.3732835Z C:\Users\buildguest.nuget\packages\buildwebcompiler\1.11.326\build\BuildWebCompiler.targets(15,9):错误 MSB4062:无法从程序集 C:\Users\ 加载“WebCompiler.CompilerBuildTask”任务buildguest.nuget\packages\buildwebcompiler\1.11.326\build..\tools\WebCompiler.exe。无法加载文件或程序集“Microsoft.Build.Utilities.v4.0,Version=4.0.0.0,Culture=neutral,PublicKeyToken=b03f5f7f11d50a3a”。该系统找不到指定的文件。确认声明正确,程序集及其所有依赖项都可用,并且任务包含实现 Microsoft.Build.Framework.ITask 的公共类。 [d:\a\1\s\MMLServices\MMLServices.csproj] 2017-06-20T15:23:37.3943585Z ##[调试]rc:1 2017-06-20T15:23:37.3943585Z ##[调试]成功:假 2017-06-20T15:23:37.3973597Z ##[错误]错误:C:\Program Files\dotnet\dotnet.exe 失败,返回码:1 2017-06-20T15:23:37.3973597Z ##[debug]Processed: ##vso[task.issue type=error;]Error: C:\Program Files\dotnet\dotnet.exe failed with return code: 1 2017-06-20T15:23:37.4003593Z ##[debug] 任务结果:失败 2017-06-20T15:23:37.4003593Z ##[错误]Dotnet 命令在以下项目中以非零退出代码失败:d:\a\1\s\MMLServices\MMLServices.csproj 2017-06-20T15:23:37.4003593Z ##[debug]Processed:##vso[task.issue type=error;]Dotnet 命令在以下项目中因非零退出代码而失败:d:\a\1\ s\MMLServices\MMLServices.csproj 2017-06-20T15:23:37.4034692Z ##[debug]Processed:##vso[task.complete result=Failed;]Dotnet 命令在以下项目中失败,退出代码为非零:d:\a\1\ s\MMLServices\MMLServices.csproj 2017-06-20T15:23:37.4073330Z ##[部分]整理:发布

【问题讨论】:

    标签: asp.net-core-mvc azure-pipelines asp.net-core-1.1


    【解决方案1】:

    该问题与使用 BuildWebCompiler 包进行 donet 构建有关。您可以改用 Visual Studio Build 任务:

    1. 删除 .NET Core 构建任务
    2. 添加 Visual Studio 构建任务(解决方案:***.sln;Visual Studio 版本:Visual Studio 2017)

    更新:

    关于发布,可以参考以下步骤(不能使用dotnet publish):

    1. 在 Visual Studio 中创建 Web 部署包发布配置文件并添加到源代码管理

    示例:

    <?xml version="1.0" encoding="utf-8"?>
    <!--
    This file is used by the publish/package process of your Web project. You can customize the behavior of this process
    by editing this MSBuild file. In order to learn more about this please visit https://go.microsoft.com/fwlink/?LinkID=208121. 
    -->
    <Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
      <PropertyGroup>
        <WebPublishMethod>Package</WebPublishMethod>
        <LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
        <LastUsedPlatform>Any CPU</LastUsedPlatform>
        <SiteUrlToLaunchAfterPublish />
        <LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
        <ExcludeApp_Data>False</ExcludeApp_Data>
        <PublishFramework>netcoreapp1.1</PublishFramework>
        <ProjectGuid>6ecb453c-aea3-44af-8185-059fbac7b56c</ProjectGuid>
        <DesktopBuildPackageLocation>E:\yy\WebApp-OpenIDConnect-DotNet.zip</DesktopBuildPackageLocation>
        <PackageAsSingleFile>true</PackageAsSingleFile>
        <DeployIisAppPath>Default Web Site/tt</DeployIisAppPath>
        <PublishDatabaseSettings>
          <Objects xmlns="" />
        </PublishDatabaseSettings>
      </PropertyGroup>
    </Project>
    
    1. 删除 .NET Core 任务(例如发布、构建)
    2. 为 Visual Studio 构建任务指定此 MSBuild 参数

    /p:DeployOnBuild=true /p:PublishProfile=[publish profile];DesktopBuildPackageLocation="$(build.artifactstagingdirectory)\WebApp-OpenIDConnect-DotNet.zip"
    

    【讨论】:

    • 这没有帮助。同样的事情。
    • @alvipeo 你能分享一下 OneDrive 上的详细构建日志吗? (将 system.debug 设置为 true>queue build>share log files)另一方面,你能用一个新项目重现这个问题吗?如果是这样,您也可以在 OneDrive 上共享此项目。
    • 如果你愿意,我可以让你访问我的 VSTS。 DM我... GitHub上有私人交流吗?
    • @alvipeo 最好直接分享构建日志和一个简单的项目。
    • 澄清一下——你想让我把这个“set system.debug to true”设置在哪里?
    【解决方案2】:

    好的,我删除了 Build 定义并添加了一个新定义 - 这次使用 ASP.NET Core (.NET Framework) 模板,一切正常。

    【讨论】:

      猜你喜欢
      • 2020-08-29
      • 2019-01-22
      • 2017-03-31
      • 2017-11-02
      • 1970-01-01
      • 2018-02-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多