Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/311.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 解决方案文件中的项目依赖关系使生成失败_C#_.net_Build_Msbuild_Dependencies - Fatal编程技术网

C# 解决方案文件中的项目依赖关系使生成失败

C# 解决方案文件中的项目依赖关系使生成失败,c#,.net,build,msbuild,dependencies,C#,.net,Build,Msbuild,Dependencies,此存储库再现了我们面临的dotnet构建问题 我们有一个针对netcoreapp2.1的web应用程序。以及一个面向netstandard2.0和net47的类库 web应用程序提供了一个web API,我们使用它来生成相应的C#client。 因此,构建过程必须首先构建web应用程序,然后构建类库 由于此要求的顺序,我们在解决方案中定义了一个项目依赖项: 但是,尽管它在Visual Studio中构建良好,但在命令行中失败: $ dotnet build dotnetBuildIssue.s

此存储库再现了我们面临的
dotnet构建
问题

我们有一个针对netcoreapp2.1的web应用程序。以及一个面向
netstandard2.0
net47
的类库

web应用程序提供了一个web API,我们使用它来生成相应的C#client。 因此,构建过程必须首先构建web应用程序,然后构建类库

由于此要求的顺序,我们在解决方案中定义了一个项目依赖项:

但是,尽管它在Visual Studio中构建良好,但在命令行中失败:

$ dotnet build dotnetBuildIssue.sln
Microsoft (R) Build Engine version 15.8.166+gd4e8d81a88 for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.

  Restore completed in 42.36 ms for C:\work\tmp\dotnetBuildIssue\ClassLib\ClassLib.csproj.
  Restore completed in 63.56 ms for C:\work\tmp\dotnetBuildIssue\WebApp\WebApp.csproj.
  WebApp -> C:\work\tmp\dotnetBuildIssue\WebApp\bin\Debug\netcoreapp2.1\WebApp.dll
C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.aspnetcore.app\2.1.1\build\netcoreapp2.1\Microsoft.AspNetCore.App.targets(14,5): error : This version of Microsoft.AspNetCore.App is only compatible with the netcoreapp2.1 target framework. Please target netcoreapp2.1 or choose a version of Microsoft.AspNetCore.App compatible with netstandard2.0. [C:\work\tmp\dotnetBuildIssue\WebApp\WebApp.csproj]
C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.aspnetcore.app\2.1.1\build\netcoreapp2.1\Microsoft.AspNetCore.App.targets(14,5): error : This version of Microsoft.AspNetCore.App is only compatible with the netcoreapp2.1 target framework. Please target netcoreapp2.1 or choose a version of Microsoft.AspNetCore.App compatible with net47. [C:\work\tmp\dotnetBuildIssue\WebApp\WebApp.csproj]

Build FAILED.
在我看来,dotnet似乎使用类库的TargetFramework
net47
来编译web应用程序,尽管我们只设置了一个项目 执行特定生成顺序的依赖项

我们的real solutions包含超过15个项目,因此添加了一个构建任务 对于VSTS Azure DevOps构建管道中的每个项目 这不是最理想的

我们希望不必在解决方案文件中定义依赖项,但我们还没有找到在.csproj文件中定义依赖项的有效方法

任何关于如何在不直接引用的情况下强制执行项目特定顺序的提示(我们针对不同的框架)都是受欢迎的


我在上发表了一篇文章。

事实上,更多的研究表明,这个问题已经并将在MSBuild 15.9中得到解决。 上述线程中还提到了一个临时修复程序:将文件Directory.Build.props放在解决方案文件旁边,其中包含以下内容:


假的

事实上,更多的研究表明,这个问题已经并将在MSBuild 15.9中得到解决。 上述线程中还提到了一个临时修复程序:将文件Directory.Build.props放在解决方案文件旁边,其中包含以下内容:


假的