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

时间:2018-06-15 20:16:41

标签: .net tfs msbuild tfsbuild .net-standard

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

引用.NET Standard 2.0项目“TimeUtility”:

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

  

项目   “C:\ TFS \ agent_work \ 21个\ S \服务\后台程序\ ReportDaemon \ ReportDaemon \ ReportDaemon.sln”   (1)正在建设中   “C:\ TFS \ agent_work \ 21 \ S \核心\ TimeUtility \ SRC \ TimeUtility \ TimeUtility.csproj”   节点1上的(14:15)(默认目标)。 PrepareForBuild:创建   目录“bin \ Release \ netcoreapp2.0 \”。 C:\ Program Files   (86)\ DOTNET \ SDK \ 2.1.200 \ SDKS \ Microsoft.NET.Sdk \建立\ Microsoft.PackageDependencyResolution.targets(167,5):   错误:资产文件   'C:\ TFS \ agent_work \ 21 \ S \核心\ TimeUtility \ SRC \ TimeUtility \ OBJ \ project.assets.json'   没有'.NETCoreApp,Version = v2.0'的目标。确保这件事   恢复已经运行,你已经包含'netcoreapp2.0'   您的项目的TargetFrameworks。 C:\ Program Files   (86)\ DOTNET \ SDK \ 2.1.200 \ SDKS \ Microsoft.NET.Sdk \建立\ Microsoft.PackageDependencyResolution.targets(167,5):   错误:资产文件   'C:\ TFS \ agent_work \ 21 \ S \核心\ TimeUtility \ SRC \ TimeUtility \ OBJ \ project.assets.json'   没有'.NETCoreApp,Version = v2.0'的目标。确保这件事   恢复已经运行,你已经包含'netcoreapp2.0'   您的项目的TargetFrameworks。   [C:\ TFS \ agent_work \ 21 \ S \核心\ TimeUtility \ SRC \ TimeUtility \ TimeUtility.csproj]   完成建筑项目   “C:\ TFS \ agent_work \ 21 \ S \核心\ 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>

.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>

编辑:添加了一些图片以供澄清

enter image description here

enter image description here

0 个答案:

没有答案