编译两个的.Net框架的一次框架、两个、Net

2023-09-03 12:00:58 作者:可许

我在C#中的计划,我希望把它编译成两个不同的.NET Framework版本。 所以,当我preSS编译按钮,它使FX。 ComputerInfo3.exe和ComputerInfo4.exe

I have a program in c# and i want to make it compile to two different .Net Framework Versions. So when i press the Compile button it makes fx. "ComputerInfo3.exe" and "ComputerInfo4.exe".

我想使用.NET框架版本3.5和4。 我使用Visual Studio和C#。 这可能吗?

I want to use version 3.5 and 4 of .Net Framework. I use Visual Studio and C#. Is this possible?

在此先感谢!

推荐答案

您最好的选择是创建两个单独的csproj文件,一个是针对3.5和一个针对4.0的,包括他们在同一个解决方案。您可以从一个项目添加的所有文件复制到其他项目。如果您链接,而不是常规添加的文件,然后任何更新您的文件中做出将适用于这两个项目。

Your best bet would be to create two separate csproj files, one that targets 3.5 and one that targets 4.0, and include them in the same solution. You can add all the files from one project to the other project. If you link the file, instead of regular add, then any updates you make in the file will be applied to both projects.

您将最有可能的运行,如果你尝试有项目在同一位置,由于是如何的Visual Studio维护临时构建文件到的问题。所以,你需要让他们在不同的文件夹。

You will most likely run into issues if you try to have the projects in the same location, due to how Visual Studio maintains temporary build files. So you'd need to keep them in separate folders.

最后,如果你建立一个可执行文件,目标3.5,那么它可以作为,是对.NET 4所以一般你不应该需要建立两个版本的EXE的。

Finally, if you build an executable that targets 3.5, then it can be run as-is on .NET 4. So in general you should not need to build two versions of the EXE.