简体   繁体   中英

How to compile a program into different projects in C#

Let us say that: I have a project, this project uses a references (office2016.dll). in my project I have ac# classes that access these references and works fine.

Now I want to compile the same code but by using different references, this time (office2012.dll). note that (office2016.dll & office2012.dll) are sharing the same methods and types that I used in my c# code. but I want to publish different (EXE) for each product. one for office 2016, and another for office 2012.

Is it possible to compile the same c# code on different references (dll)?

One solution is to copy my c# code in a new project and then add the other (office2012.dll) and then recompile again, it works and fine but I would n't like to do that manually because I work every day and it requires many efforts and concentrations and of course extra time, because really I don't believe on copy/paste code, this is actually a tedious work!

You can create copies of the project file (the .csproj ) in the same folder , then include the copied project(s) in your solution. You can then pick the correct references for each project. Make sure to go to the project properties and choose a custom assembly name and/or output folder for each project (ie. myoffice2012app.exe and/or bin/Release2012 ).

Any code file you add afterwards will have to be included in each copy, but this is simplified by selecting "show all files":

在此处输入图片说明

right-clicking the new files and selecting "Include In Project" - but besides having to add each new code file to each project separately, you can build the solution as often as you want without further steps needed.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM