NSWAG 更新到 .NET6 - .NETPlatform,版本=v6.0 未找到
我已将解决方案中的所有项目更新为使用 .net6,并将 nswag json 文件更新为 runtime
到 Net60。
我安装了.net 6.0.100。
这是构建输出
$ dotnet build Solution.sln
Microsoft (R) Build Engine ersion 17.0.0+c9eb9dd64 for .NET
Restored C:\src\...\Client.csproj (in 455 ms).
NSwag command line tool for .NET Core Net60, toolchain v13.15.10.0 (NJsonSchema v10.6.10.0 (Newtonsoft.Json v13.0.0.0))
NSwag bin directory: C:\Users\...\.nuget\packages\nswag.msbuild\13.15.10\tools\Net60
Executing file 'nswag.json' with variables 'Configuration=Debug'...
C:\Program Files\dotnet\sdk\6.0.100\Microsoft.Common.CurrentVersion.targets(1217,5): error MSB3644: The reference assemblies for .NETPlatform,Version=v6.0 were not found. To resolve this, install the Developer Pack (SDK/Targeting Pack) for this framework version or retarget your application. You can download .NET Framework Developer Packs at https://aka.ms/msbuild/developerpacks [C:\src\API.csproj] [C:\src\...\.Client.csproj]
System.InvalidOperationException: Unable to retrieve project metadata. Ensure it's an MSBuild-based .NET Core project.If you're using custom BaseIntermediateOutputPath or MSBuildProjectExtensionsPath values, Use the --msbuildprojectextensionspath option.
at NSwag.Commands.Generation.AspNetCore.ProjectMetadata.GetProjectMetadata(String file, String buildExtensionsDir, String framework, String configuration, String runtime, Boolean noBuild, String outputPath, IConsoleHost console) in /_/src/NSwag.Commands/Commands/Generation/AspNetCore/ProjectMetadata.cs:line 152
C:\src\....Client.csproj(15,5): error MSB3073: The command "dotnet "C:\Users\...\.nuget\packages\nswag.msbuild\13.15.10\build\../tools/Net60/dotnet-nswag.dll" run nswag.json /variables:Configuration=Debug" exited with code -1.
C:\Program Files\dotnet\sdk\6.0.100\Microsoft.Common.CurrentVersion.targets(1217,5): error MSB3644: The reference assemblies for .NETPlatform,Version=v6.0 were not found. To resolve this, install the Developer Pack (SDK/Targeting Pack) for this framework version or retarget your application. You can download .NET Framework Developer Packs at https://aka.ms/msbuild/developerpacks [C:\src\API.csproj] [C:\src\...\Client.csproj]
C:\src\...\.Client.csproj(15,5): error MSB3073: The command "dotnet "C:\Users\...\.nuget\packages\nswag.msbuild\13.15.10\build\../tools/Net60/dotnet-nswag.dll" run nswag.json /variables:Configuration=Debug" exited with code -1.
I've updated all projects in my solution to use .net6, and have updated nswag json file to runtime
to Net60.
I have .net 6.0.100 installed.
Here is the build output
$ dotnet build Solution.sln
Microsoft (R) Build Engine ersion 17.0.0+c9eb9dd64 for .NET
Restored C:\src\...\Client.csproj (in 455 ms).
NSwag command line tool for .NET Core Net60, toolchain v13.15.10.0 (NJsonSchema v10.6.10.0 (Newtonsoft.Json v13.0.0.0))
NSwag bin directory: C:\Users\...\.nuget\packages\nswag.msbuild\13.15.10\tools\Net60
Executing file 'nswag.json' with variables 'Configuration=Debug'...
C:\Program Files\dotnet\sdk\6.0.100\Microsoft.Common.CurrentVersion.targets(1217,5): error MSB3644: The reference assemblies for .NETPlatform,Version=v6.0 were not found. To resolve this, install the Developer Pack (SDK/Targeting Pack) for this framework version or retarget your application. You can download .NET Framework Developer Packs at https://aka.ms/msbuild/developerpacks [C:\src\API.csproj] [C:\src\...\.Client.csproj]
System.InvalidOperationException: Unable to retrieve project metadata. Ensure it's an MSBuild-based .NET Core project.If you're using custom BaseIntermediateOutputPath or MSBuildProjectExtensionsPath values, Use the --msbuildprojectextensionspath option.
at NSwag.Commands.Generation.AspNetCore.ProjectMetadata.GetProjectMetadata(String file, String buildExtensionsDir, String framework, String configuration, String runtime, Boolean noBuild, String outputPath, IConsoleHost console) in /_/src/NSwag.Commands/Commands/Generation/AspNetCore/ProjectMetadata.cs:line 152
C:\src\....Client.csproj(15,5): error MSB3073: The command "dotnet "C:\Users\...\.nuget\packages\nswag.msbuild\13.15.10\build\../tools/Net60/dotnet-nswag.dll" run nswag.json /variables:Configuration=Debug" exited with code -1.
C:\Program Files\dotnet\sdk\6.0.100\Microsoft.Common.CurrentVersion.targets(1217,5): error MSB3644: The reference assemblies for .NETPlatform,Version=v6.0 were not found. To resolve this, install the Developer Pack (SDK/Targeting Pack) for this framework version or retarget your application. You can download .NET Framework Developer Packs at https://aka.ms/msbuild/developerpacks [C:\src\API.csproj] [C:\src\...\Client.csproj]
C:\src\...\.Client.csproj(15,5): error MSB3073: The command "dotnet "C:\Users\...\.nuget\packages\nswag.msbuild\13.15.10\build\../tools/Net60/dotnet-nswag.dll" run nswag.json /variables:Configuration=Debug" exited with code -1.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

我确实找到了一个解决方法——它让我解决了这个问题。
的
project
元素中引用该项目时,它会失败。在
nswag.json
文件中,当我在So removeproject
. >并在
assemblePaths[]
数组中引用项目的输出 DLL。它构建成功&客户端已重新生成。
I did find a workaround - it gets me past the problem.
In the
nswag.json
file, it fails when I reference the project in theproject
element ofSo remove
project
.And reference the output DLL from your project in the
assemblyPaths[]
array.It builds successfully & the client is regenerated.