将 .NET Core 从 1.X 升级到 2.0 后 Visual Studio Team Services CI 出错 (NU1105)

Error in Visual Studio Team Services CI after upgrading .NET Core from 1.X to 2.0 (NU1105)

将 ASP.NET Core 应用程序从 .NET Core 1.X 升级到 2.0 后,Visual Studio Team Services CI 在 restore/build/test 上失败。

错误是

error NU1105: Unable to find project information for '[Project Path]/Portal.csproj'. The project file may be invalid or missing targets required for restore.

错误发生在 VSTS 尝试构建测试项目后,例如Portal.Tests.csproj 引用 Portal.csproj

在Portal.csproj中,您需要删除或注释掉以下行:

<DotNetCliToolReference Include="BundlerMinifier.Core" Version="X.X.XXX" />

这似乎导致 VSTS 出现问题。

如果有人因为这个问题而对 .net 发布命令有问题,请附加说明。

从 .net 1.1 升级到 2.0 后,升级向导在 csproj 文件中留下了以下行,这导致我们构建的发布阶段失败。

<Target Name="PrepublishScript" BeforeTargets="PrepareForPublish">
    <Exec Command="dotnet bundle" />
</Target>

删除 dotnet bundle 行修复了发布。

似乎捆绑过程已内置到 Web 应用程序的构建中,这意味着不需要 .net 1.x 中包含的额外预发布步骤。所需要做的就是向 BuildBundlerMinifier 添加依赖项,然后它会处理 bundleconfig.json 文件中的指令,这些文件包含在所有默认的 .net core 2.0 Web 应用程序

1>------ Build started: Project: BundleTest, Configuration: Release Any CPU ------
1>
1>Bundler: Begin processing bundleconfig.json
1>Bundler: Done processing bundleconfig.json
1>BundleTest -> C:\Source\Repos\BundleTest\BundleTest\bin\Release\netcoreapp2.0\BundleTest.dll