【问题标题】:Angular4.1 with .NET Core1.1 build fails in VSTS Hosted VS2017 agent带有 .NET Core1.1 构建的 Angular4.1 在 VSTS 托管的 VS2017 代理中失败
【发布时间】:2017-10-28 12:14:45
【问题描述】:

我有一个位于 .NET Core 1.1 上的 Angular 4.1.1 应用程序,我最近从带有更新 3 的 VS2015 迁移到 VS2017。我的 csproj 在我的本地机器上构建并运行良好,但在通过其托管的 VS2017 代理在 VSTS 上设置构建时失败。

失败发生在“构建”步骤,这里是日志文件中指出原因的部分:

Installed:
2017-05-27T14:23:05.5884539Z       301 package(s) to d:\a\1\s\src\MyApp.Web\MyApp.Web.csproj
2017-05-27T14:23:05.6244543Z ##[section]Finishing: Restore
2017-05-27T14:23:05.6254542Z ##[section]Starting: Build
2017-05-27T14:23:05.6264541Z ==============================================================================
2017-05-27T14:23:05.6264541Z Task         : .NET Core
2017-05-27T14:23:05.6264541Z Description  : Build, test and publish using dotnet core command-line.
2017-05-27T14:23:05.6264541Z Version      : 1.0.1
2017-05-27T14:23:05.6264541Z Author       : Microsoft Corporation
2017-05-27T14:23:05.6264541Z Help         : [More Information](https://go.microsoft.com/fwlink/?linkid=832194)
2017-05-27T14:23:05.6264541Z ==============================================================================
2017-05-27T14:23:05.9804666Z [command]"C:\Program Files\dotnet\dotnet.exe" build d:\a\1\s\src\MyApp.Web\Gitrub.Web.csproj --configuration release
2017-05-27T14:23:09.2404951Z Microsoft (R) Build Engine version 15.1.1012.6693
2017-05-27T14:23:09.2404951Z Copyright (C) Microsoft Corporation. All rights reserved.
2017-05-27T14:23:09.2404951Z 
2017-05-27T14:23:14.7693001Z C:\Users\buildguest\.nuget\packages\microsoft.typescript.msbuild\2.2.2\tools\microsoft.TypeScript.targets(168,5): error MSB4062: The "TypeScript.Tasks.FindConfigFiles" task could not be loaded from the assembly C:\Users\buildguest\.nuget\packages\microsoft.typescript.msbuild\2.2.2\tools\TypeScript.tasks.dll. Could not load file or assembly 'Microsoft.Build.Utilities.v4.0, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified. Confirm that the <UsingTask> declaration is correct, that the assembly and all its dependencies are available, and that the task contains a public class that implements Microsoft.Build.Framework.ITask. [d:\a\1\s\src\MyApp.Web\MyApp.Web.csproj]
2017-05-27T14:23:15.0284154Z 
2017-05-27T14:23:15.0284154Z Build FAILED.
2017-05-27T14:23:15.0284154Z 
2017-05-27T14:23:15.0284154Z C:\Users\buildguest\.nuget\packages\microsoft.typescript.msbuild\2.2.2\tools\microsoft.TypeScript.targets(168,5): error MSB4062: The "TypeScript.Tasks.FindConfigFiles" task could not be loaded from the assembly C:\Users\buildguest\.nuget\packages\microsoft.typescript.msbuild\2.2.2\tools\TypeScript.tasks.dll. Could not load file or assembly 'Microsoft.Build.Utilities.v4.0, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified. Confirm that the <UsingTask> declaration is correct, that the assembly and all its dependencies are available, and that the task contains a public class that implements Microsoft.Build.Framework.ITask. [d:\a\1\s\src\MyApp.Web\MyApp.Web.csproj]
2017-05-27T14:23:15.0284154Z     0 Warning(s)
2017-05-27T14:23:15.0284154Z     1 Error(s)
2017-05-27T14:23:15.0294178Z 
2017-05-27T14:23:15.0294178Z Time Elapsed 00:00:05.73
2017-05-27T14:23:15.0564018Z ##[error]Error: C:\Program Files\dotnet\dotnet.exe failed with return code: 1
2017-05-27T14:23:15.0564018Z ##[error]Dotnet command failed with non-zero exit code on the following projects : d:\a\1\s\src\MyApp.Web\MyApp.Web.csproj

我在 VSTS 网站上注意到 Typescript 不包含在 VS2017 托管代理(以及最高 v2.0.6 的“托管”代理)支持的内容中,我认为这可能是上述原因错误,但是在我将应用程序迁移到 VS2017 之前,我已经能够在“托管”代理上成功运行构建,同时使用我现在尝试部署的相同版本 (2.2) 的打字稿..

如果有人能帮我解决这个问题,我将不胜感激。这是我的csproj供参考:

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

  <PropertyGroup>
    <TargetFramework>netcoreapp1.1</TargetFramework>
    <PreserveCompilationContext>true</PreserveCompilationContext>
    <AssemblyName>MyApp.Web</AssemblyName>
    <OutputType>Exe</OutputType>
    <PackageId>MyApp.Web</PackageId>
    <RuntimeFrameworkVersion>1.1.1</RuntimeFrameworkVersion>
    <PackageTargetFallback>$(PackageTargetFallback);dotnet5.6;portable-net45+win8</PackageTargetFallback>
  </PropertyGroup>

  <ItemGroup>
    <None Update="wwwroot\**\*">
      <CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
    </None>
  </ItemGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.AspNetCore.Diagnostics" Version="1.1.1" />
    <PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="1.1.2" />
    <PackageReference Include="Microsoft.AspNetCore.Server.IISIntegration" Version="1.1.2" />
    <PackageReference Include="Microsoft.AspNetCore.Server.Kestrel" Version="1.1.1" />
    <PackageReference Include="Microsoft.EntityFrameworkCore" Version="1.1.2" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="1.1.2" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="1.1.1" />
    <PackageReference Include="Microsoft.Extensions.Logging.Console" Version="1.1.1" />
    <PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.1.2" />
    <PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="1.1.1" />
    <PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="1.1.1" />
    <PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="1.1.1" />
    <PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="1.1.1" />
    <PackageReference Include="Microsoft.TypeScript.Compiler" Version="2.2.1" />
    <PackageReference Include="Microsoft.TypeScript.MSBuild" Version="2.2.2" />
  </ItemGroup>

</Project>

【问题讨论】:

    标签: angular typescript azure-pipelines asp.net-core-1.1


    【解决方案1】:

    我最近设置了一个类似的构建并遇到了同样的问题。我能够通过为“dotnet restore”添加一个 .NET Core 步骤来解决它。

    【讨论】:

    • 感谢您的回复。我不确定你到底指的是什么。在“构建”步骤之前有一个“恢复”步骤,这一步很顺利。除此之外,我没有关注..
    【解决方案2】:

    改用 Microsoft.TypeScript.MSBuild 2.3.3。 (2.2.2 有问题)。

    这是我的csproj(不需要添加Microsoft.TypeScript.Compiler包)

    <Project Sdk="Microsoft.NET.Sdk.Web">
    
      <PropertyGroup Label="Globals">
        <SccProjectName>SAK</SccProjectName>
        <SccProvider>SAK</SccProvider>
        <SccAuxPath>SAK</SccAuxPath>
        <SccLocalPath>SAK</SccLocalPath>
      </PropertyGroup>
    
      <PropertyGroup>
        <TargetFramework>netcoreapp1.1</TargetFramework>
      </PropertyGroup>
    
      <PropertyGroup>
        <PackageTargetFallback>$(PackageTargetFallback);portable-net45+win8+wp8+wpa81;</PackageTargetFallback>
      </PropertyGroup>
      <ItemGroup>
        <PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.0.0" />
        <PackageReference Include="Microsoft.AspNetCore" Version="1.1.1" />
        <PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.1.2" />
        <PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="1.1.1" />
        <PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="1.1.1" />
        <PackageReference Include="Microsoft.TypeScript.MSBuild" Version="2.3.3" />
        <PackageReference Include="Microsoft.VisualStudio.Web.BrowserLink" Version="1.1.0" />
      </ItemGroup>
      <ItemGroup>
        <DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="1.0.0" />
      </ItemGroup>
    
    </Project>
    

    注意:根据我的测试,Typescript 2.1 可用于 Hosted VS2017 代理。

    【讨论】:

    • 感谢您的回复。将 Microsoft.Typescript.MSBuild 更新到 2.3.3 会导致 VSTS 中出现不同的构建错误,例如“找不到模块 '@angular/core'”和所有其他 angular 模块。但是,升级到 2.3.3 后,我仍然可以在我的机器上构建和运行良好。想法?
    • 你能在onedrive上分享一个简单的应用程序吗?
    • 如果直接使用typescript 2.1会有什么结果? (删除 Microsoft.Typescript.MSBuild 和 Microsoft.TypeScript.Compiler 包)
    猜你喜欢
    • 2017-08-08
    • 1970-01-01
    • 2017-12-19
    • 2016-10-24
    • 1970-01-01
    • 2018-03-02
    • 2016-04-07
    • 2020-01-01
    • 2017-01-07
    相关资源
    最近更新 更多