[英]dotnet build for .net framework 4.7.2 project results in "The framework 'Microsoft.NETCore.App', version '6.0.3' (x64) was not found"
I have a .net framework 4.7.2 web API assembly that I've been building for a while using the command:我有一个 .net framework 4.7.2 Web API 程序集,我已经使用以下命令构建了一段时间:
dotnet build 'D:\proj\folder\main\source\MyProj.WebApi\MyProj.WebApi.csproj'
-t:Rebuild -p:Configuration=Debug -p:OutDir='D:\Projects\MyProj\Main\Build\Deployment
Packages\.temp\Assemblies'
-detailedSummary:True
This has worked with no problems until now and I'm not sure what changed.到目前为止,这一直没有问题,我不确定发生了什么变化。
The exception I get is the following:我得到的例外如下:
It was not possible to find any compatible framework version The framework 'Microsoft.NETCore.App', version '6.0.3' (x64) was not found.找不到任何兼容的框架版本找不到框架“Microsoft.NETCore.App”,版本“6.0.3”(x64)。
- The following frameworks were found: 2.1.28 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] 2.1.30 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] 3.1.17 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] 3.1.23 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] 5.0.8 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] 5.0.9 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] 5.0.15 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] 6.0.0 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] 6.0.2 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]找到了以下框架:2.1.28 在 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] 2.1.30 在 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] 3.1。 17 在 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] 3.1.23 在 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] 5.0.8 在 [C:\Program Files \dotnet\shared\Microsoft.NETCore.App] 5.0.9 在 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] 5.0.15 在 [C:\Program Files\dotnet\shared\Microsoft.NETCore .App] 6.0.0 在 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] 6.0.2 在 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
You can resolve the problem by installing the specified framework and/or SDK.您可以通过安装指定的框架和/或 SDK 来解决问题。
This is odd since this is not a .netcore app/library.这很奇怪,因为这不是 .netcore 应用程序/库。
My project uses PackageReferences format so I have all packages referenced in the csproj file:我的项目使用 PackageReferences 格式,因此我在 csproj 文件中引用了所有包:
<ItemGroup>
<PackageReference Include="AutoMapper" Version="10.0.0" />
<PackageReference Include="DotNetNuke.Core" Version="9.7.2" />
<PackageReference Include="DotNetNuke.DependencyInjection" Version="9.7.2" />
<PackageReference Include="DotNetNuke.Instrumentation" Version="9.7.2" />
<PackageReference Include="DotNetNuke.Web" Version="9.7.2" />
<PackageReference Include="DotNetNuke.WebApi" Version="9.7.2" />
<PackageReference Include="EntityFramework" Version="6.4.4" />
<PackageReference Include="Microsoft.AspNet.WebApi.Client" Version="5.2.3" />
<PackageReference Include="Microsoft.AspNet.WebApi.Core" Version="5.2.3" />
<PackageReference Include="Newtonsoft.Json" Version="10.0.3" />
<PackageReference Include="System.Collections.NonGeneric" Version="4.3.0" />
</ItemGroup>
I've confirmed that the target framework in the csproj file is net472:我已经确认csproj文件中的目标框架是net472:
<PropertyGroup>
<ProjectGuid>{4B5038E2-757F-4C80-A41D-2E3D7035B02F}</ProjectGuid>
<TargetFramework>net472</TargetFramework>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<Deterministic>true</Deterministic>
<BaseOutputPath>bin\</BaseOutputPath>
</PropertyGroup>
The project does reference a number of other projects, but all of these also target net472.该项目确实引用了许多其他项目,但所有这些项目也都针对 net472。
What else can I do to find the cause?我还能做些什么来找到原因?
I eventually found the answer to this, add the following line to your project file我最终找到了答案,将以下行添加到您的项目文件中
<AzureFunctionsVersion>v1</AzureFunctionsVersion>
I added this after the TargetFramework tag.我在 TargetFramework 标记之后添加了这个。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.