由于'project.assets.json'没有.NETCoreApp,Version2.0的目标,TFS-CI构建失败

Luk*_*e G 5 .net msbuild tfs tfsbuild .net-standard

我的控制台项目正在运行4.7.1(<TargetFrameworkVersion>v4.7.1</TargetFrameworkVersion>)

它引用了.NET Standard 2.0项目"TimeUtility":

解决方案在本地构建良好,但CI构建中出现以下错误:

项目"C:\ TFS\agent_work\21\s\Services\Daemons\ReportDaemon\ReportDaemon\ReportDaemon.sln"(1)正在构建"C:\ TFS\agent_work\21\s\Core\TimeUtility\src\TimeUtility \节点1上的TimeUtility.csproj"(14:15)(默认目标).PrepareForBuild:创建目录"bin\Release \netcoreapp2.0 \".C:\ Program Files(x86)\ dotnet\sdk\2.1.200\Sdks\Microsoft.NET.Sdk\build\Microsoft.PackageDependencyResolution.targets(167,5):错误:资产文件'C:\ TFS\agent_work\21\s\Core\TimeUtility\src\TimeUtility\obj\project.assets.json'没有'.NETCoreApp,Version = v2.0'的目标.确保还原已运行,并且已在项目的TargetFrameworks中包含"netcoreapp2.0".C:\ Program Files(x86)\ dotnet\sdk\2.1.200\Sdks\Microsoft.NET.Sdk\build\Microsoft.PackageDependencyResolution.targets(167,5):错误:资产文件'C:\ TFS\agent_work\21\s\Core\TimeUtility\src\TimeUtility\obj\project.assets.json'没有'.NETCoreApp,Version = v2.0'的目标.确保还原已运行,并且已在项目的TargetFrameworks中包含"netcoreapp2.0".[C:\ TFS\agent_work\21\s\Core\TimeUtility\src\TimeUtility\TimeUtility.csproj]完成构建项目"C:\ TFS\agent_work\21\s\Core\TimeUtility\src\TimeUtility\TimeUtility.csproj "(默认目标) - 失败.

我尝试过多种想法,但到目前为止已经成功了.

.Net Framework 4.7.1

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
  <PropertyGroup>
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
    <ProjectGuid>{66A8B6CC-ED2E-43B5-B91E-6F018B827DD4}</ProjectGuid>
    <OutputType>Exe</OutputType>
    <RootNamespace>ReportDaemon</RootNamespace>
    <AssemblyName>ReportDaemon</AssemblyName>
    <TargetFrameworkVersion>v4.7.1</TargetFrameworkVersion>
    <FileAlignment>512</FileAlignment>
    <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
    <SccProjectName>SAK</SccProjectName>
    <SccLocalPath>SAK</SccLocalPath>
    <SccAuxPath>SAK</SccAuxPath>
    <SccProvider>SAK</SccProvider>
    <PublishUrl>publish\</PublishUrl>
    <Install>true</Install>
    <InstallFrom>Disk</InstallFrom>
    <UpdateEnabled>false</UpdateEnabled>
    <UpdateMode>Foreground</UpdateMode>
    <UpdateInterval>7</UpdateInterval>
    <UpdateIntervalUnits>Days</UpdateIntervalUnits>
    <UpdatePeriodically>false</UpdatePeriodically>
    <UpdateRequired>false</UpdateRequired>
    <MapFileExtensions>true</MapFileExtensions>
    <ApplicationRevision>0</ApplicationRevision>
    <ApplicationVersion>1.0.0.%2a</ApplicationVersion>
    <IsWebBootstrapper>false</IsWebBootstrapper>
    <UseApplicationTrust>false</UseApplicationTrust>
    <BootstrapperEnabled>true</BootstrapperEnabled>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
    <PlatformTarget>AnyCPU</PlatformTarget>
    <DebugSymbols>true</DebugSymbols>
    <DebugType>full</DebugType>
    <Optimize>false</Optimize>
    <OutputPath>bin\Debug\</OutputPath>
    <DefineConstants>DEBUG;TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
    <PlatformTarget>AnyCPU</PlatformTarget>
    <DebugType>pdbonly</DebugType>
    <Optimize>true</Optimize>
    <OutputPath>bin\Release\</OutputPath>
    <DefineConstants>TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
  </PropertyGroup>
  <PropertyGroup>
    <StartupObject>
    </StartupObject>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="System.Data.SqlClient" Version="4.4.0" />
    <PackageReference Include="System.Runtime">
      <Version>4.3.0</Version>
    </PackageReference>
  </ItemGroup>
  <ItemGroup>
    <Reference Include="System" />
    <Reference Include="System.Configuration" />
    <Reference Include="System.Core" />
    <Reference Include="System.Web.Extensions" />
    <Reference Include="System.Xml.Linq" />
    <Reference Include="System.Data.DataSetExtensions" />
    <Reference Include="Microsoft.CSharp" />
    <Reference Include="System.Data" />
    <Reference Include="System.Xml" />
    <Reference Include="netstandard" />
  </ItemGroup>
  <ItemGroup>
    <Compile Include="Program.cs" />
  </ItemGroup>
  <ItemGroup>
    <None Include="App.config">
      <SubType>Designer</SubType>
    </None>
    <None Include="NLog.config">
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    </None>
    <None Include="Unity.config">
      <SubType>Designer</SubType>
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </None>
  </ItemGroup>
  <ItemGroup>        
    <ProjectReference Include="..\..\..\..\..\Core\TimeUtility\src\TimeUtility\TimeUtility.csproj">
      <Project>{183d4773-b251-4989-9fc3-e0d2647d477e}</Project>
      <Name>TimeUtility</Name>
    </ProjectReference>        
  </ItemGroup>
  <ItemGroup>
    <Content Include="ServiceConfig.xml" />
    <Content Include="Templates\ReportFailed.html">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </Content>
    <Content Include="Templates\ReportReady.html">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </Content>
  </ItemGroup>
  <ItemGroup>
    <BootstrapperPackage Include=".NETFramework,Version=v4.7.1">
      <Visible>False</Visible>
      <ProductName>Microsoft .NET Framework 4.7.1 %28x86 and x64%29</ProductName>
      <Install>true</Install>
    </BootstrapperPackage>
    <BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
      <Visible>False</Visible>
      <ProductName>.NET Framework 3.5 SP1</ProductName>
      <Install>false</Install>
    </BootstrapperPackage>
  </ItemGroup>
  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
Run Code Online (Sandbox Code Playgroud)

.Net Standard 2.0 csproj:

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

  <PropertyGroup Label="Globals">
    <SccProjectName>SAK</SccProjectName>
    <SccProvider>SAK</SccProvider>
    <SccAuxPath>SAK</SccAuxPath>
    <SccLocalPath>SAK</SccLocalPath>
  </PropertyGroup>

  <PropertyGroup>
    <TargetFramework>netstandard2.0</TargetFramework>
    <AssemblyName>TimeUtility</AssemblyName>
    <PackageId>TimeUtility</PackageId>

    <GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
    <GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
    <GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
  </PropertyGroup>

</Project>
Run Code Online (Sandbox Code Playgroud)

编辑:添加了一些图像以便澄清

在此输入图像描述

在此输入图像描述