Compile to two .NET Frameworks at once
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 ma开发者_如何学JAVAkes, for example, "ComputerInfo3.exe" and "ComputerInfo4.exe".
I want to use version 3.5 and 4 of the .NET Framework. I use Visual Studio and C#. Is this possible?
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.
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.
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.
You could also use nAnt for automate builds and then you can configure several targets, each one for each framework
精彩评论