Asp.net core mvc VSTS CI-ASP.NET Core 1.1的生成失败-找不到Microsoft.Build.Utilities.v4.0

Asp.net core mvc VSTS CI-ASP.NET Core 1.1的生成失败-找不到Microsoft.Build.Utilities.v4.0,asp.net-core-mvc,azure-pipelines,asp.net-core-1.1,Asp.net Core Mvc,Azure Pipelines,Asp.net Core 1.1,我为我的ASP.NET Core 1.1项目设置了CI,该项目使用Azure AD B2C(来自本例-)。下面是我在.csproj文件中的内容: <Project Sdk="Microsoft.NET.Sdk.Web"> <PropertyGroup> <TargetFramework>netcoreapp1.1</TargetFramework> <MvcRazorCompileOnPublish>true<

我为我的ASP.NET Core 1.1项目设置了CI,该项目使用Azure AD B2C(来自本例-)。下面是我在.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>

netcoreapp1.1
真的
真的
$(PackageTargetFallback);便携式-net45+win8+wp8+wpa81;
...
当我转到VSTS时,我会看到以下带有错误的日志:


开始:构建

****************************************************************************** 任务:。网络核心 描述:使用dotnetcore命令行构建、测试和发布。 版本:1.0.2 作者:微软公司

帮助: “C:\Program Files\dotnet\dotnet.exe”生成d:\a\1\s\MMLServices\MMLServices.csproj--配置发布 Microsoft(R)生成引擎版本15.1.1012.6693 版权所有(C)微软公司。版权所有

C:\Users\buildguest.nuget\packages\buildwebcompiler\1.11.326\build\buildwebcompiler.targets(15,9):错误MSB4062:无法从程序集C:\Users\buildguest.nuget\packages\buildwebcompiler\1.11.326\build..\tools\WebCompiler.exe加载“WebCompiler.Compiler”任务。无法加载文件或程序集“Microsoft.Build.Utilities.v4.0,版本=4.0.0.0,区域性=中性,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:\Users\buildguest.nuget\packages\buildwebcompiler\1.11.326\build..\tools\WebCompiler.exe加载“WebCompiler.Compiler”任务。无法加载文件或程序集“Microsoft.Build.Utilities.v4.0,版本=4.0.0.0,区域性=中性,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[命令]“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)构建引擎版本15.1.1012.6693 2017-06-20T15:23:36.7758030Z版权所有(C)微软公司。版权所有。 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\buildguest.nuget\packages\buildwebcompiler\1.11.326\build..\tools\WebCompiler.exe加载“WebCompiler.Compiler”任务。无法加载文件或程序集“Microsoft.Build.Utilities.v4.0,版本=4.0.0.0,区域性=中性,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###[调试]已处理:##vso[task.issue type=error;]错误:C:\Program Files\dotnet\dotnet.exe失败,返回代码:1 2017-06-20T15:23:37.4003593Z##[调试]任务结果:失败 2017-06-20T15:23:37.4003593Z###[错误]Dotnet命令在以下项目上失败,退出代码为非零:d:\a\1\s\MMLServices\MMLServices.csproj 2017-06-20T15:23:37.4003593Z###[debug]已处理:##vso[task.issue type=error;]Dotnet命令在以下项目上失败,退出代码为非零:d:\a\1\s\MMLServices\MMLServices.csproj 2017-06-20T15:23:37.4034692Z###[debug]已处理:##vso[task.complete result=Failed;]Dotnet命令在以下项目上失败,退出代码为非零:d:\a\1\s\MMLServices\MMLServices.csproj 2017-06-20T15:23:37.4073330Z###[部分]整理:发布


这个问题与BuildWebCompiler包的DoDonet构建有关。您可以改用Visual Studio生成任务:

  • 删除.NET核心构建任务
  • 添加Visual Studio生成任务(解决方案:**.sln;Visual Studio版本:Visual Studio 2017)
  • 更新:

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

  • 在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>
    

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

    这没有帮助。同样的事情。@alvipeo你能在OneDrive上共享详细的构建日志吗?(将system.debug设置为true>队列生成>共享日志文件)另一方面,是否可以用新项目重现此问题?如果是,您可以共享此项目
    /p:DeployOnBuild=true /p:PublishProfile=[publish profile];DesktopBuildPackageLocation="$(build.artifactstagingdirectory)\WebApp-OpenIDConnect-DotNet.zip"