如何在 VS Code 中使用 .net 4.5 版本创建 .net 项目

问题描述 投票:0回答:1

我想在 4.5 版本中创建一个 .net 项目,因为我想从 NuGet 下载一个名为 ZKFinger 的库

当我尝试

dotnet new console
时,它将创建.net 8.0版本

C:\Users\nadarraj\Desktop\ZKFinger Standard SDK 5.3.0.33\C#\ZKFinger\ZKFinger.csproj : warning NU1701: Package 'Xpeach.ZKFinger 1.0.0.3' was restored using '.NETFra
mework,Version=v4.6.1, .NETFramework,Version=v4.6.2, .NETFramework,Version=v4.7, .NETFramework,Version=v4.7.1, .NETFramework,Version=v4.7.2, .NETFramework,Version=v
4.8, .NETFramework,Version=v4.8.1' instead of the project target framework 'net8.0'. This package may not be fully compatible with your project.
C:\Users\nadarraj\Desktop\ZKFinger Standard SDK 5.3.0.33\C#\ZKFinger\ZKFinger.csproj : error NU1202: Package Xpeach.libzkfpcsharp.dll 1.0.1 is not compatible with n 
et8.0 (.NETCoreApp,Version=v8.0). Package Xpeach.libzkfpcsharp.dll 1.0.1 supports:
C:\Users\nadarraj\Desktop\ZKFinger Standard SDK 5.3.0.33\C#\ZKFinger\ZKFinger.csproj : error NU1202:   - x64 (x64,Version=v0.0)
C:\Users\nadarraj\Desktop\ZKFinger Standard SDK 5.3.0.33\C#\ZKFinger\ZKFinger.csproj : error NU1202:   - x86 (x86,Version=v0.0)

The build failed. Fix the build errors and run again.

我尝试将.csproj从

<TargetFramework>net8.0</TargetFramework>
更改为
<TargetFramework>net4.5</TargetFramework>
,然后
<TargetFramework>net45</TargetFramework>
突然库说它不支持4.5

C:\Users\nadarraj\Desktop\ZKFinger Standard SDK 5.3.0.33\C#\ZKFinger\ZKFinger.csproj : error NU1202: Package Xpeach.libzkfpcsharp.dll 1.0.1 is not compatible with n
et45 (.NETFramework,Version=v4.5). Package Xpeach.libzkfpcsharp.dll 1.0.1 supports:
C:\Users\nadarraj\Desktop\ZKFinger Standard SDK 5.3.0.33\C#\ZKFinger\ZKFinger.csproj : error NU1202:   - x64 (x64,Version=v0.0)
C:\Users\nadarraj\Desktop\ZKFinger Standard SDK 5.3.0.33\C#\ZKFinger\ZKFinger.csproj : error NU1202:   - x86 (x86,Version=v0.0)
C:\Users\nadarraj\Desktop\ZKFinger Standard SDK 5.3.0.33\C#\ZKFinger\ZKFinger.csproj : error NU1202: Package Xpeach.libzkfpcsharp.dll 1.0.1 is not compatible with n 
et45 (.NETFramework,Version=v4.5) / win7-x86. Package Xpeach.libzkfpcsharp.dll 1.0.1 supports:
C:\Users\nadarraj\Desktop\ZKFinger Standard SDK 5.3.0.33\C#\ZKFinger\ZKFinger.csproj : error NU1202:   - x64 (x64,Version=v0.0)
C:\Users\nadarraj\Desktop\ZKFinger Standard SDK 5.3.0.33\C#\ZKFinger\ZKFinger.csproj : error NU1202:   - x86 (x86,Version=v0.0)

The build failed. Fix the build errors and run again.

然后我将其更改为

<TargetFramework>net4.8</TargetFramework>
<TargetFramework>net4.8.1</TargetFramework>
,就像他们说的支持但它也不起作用

c# .net c#-4.0 nuget csproj
1个回答
0
投票

首先,您需要安装 Visual Studio 2019 构建工具。确保安装了 4.5.2 版本。

https://visualstudio.microsoft.com/vs/older-downloads/#visual-studio-2019-and-other-products

然后,使用所需的框架更新 csproj。

<TargetFramework>net452</TargetFramework>

请记住,您确实应该升级到

net48
或只是迁移到最新版本。

© www.soinside.com 2019 - 2024. All rights reserved.