简体   繁体   中英

Compile two versions of C# program automatically

I have to make the same program for two different companies (different logo, different name). I would like to have this done automatically when I do a release.

I am thinking to use a resource file or a satellite assembly, but I am not sure how to proceed.

Which way do you think is the best?

Thanks.

EDIT:

  • The differences are only one image and one string.
  • I would like to have everything generated in one click.
  • We might get more clients in the future.
  • I must also add that I use SmartAssembly to merge all my dependencies into one exe file.

You could create a class library that contains 99% of the code, and then have two projects which each reference the common library with the 1% that differs for each company. Then a build of the whole solution will generate an executable for each company. Use this if the differences between what each company wants is just enough that you need to have [slightly] different code.

Alternatively, you could make the sections that vary dependent on data, not code. In this case, it might mean getting the logo from a file, rather than embedding it in the executable, and having a configuration xml file with the company name. This would allow you to have just a single executable for both companies.

Resource string in separate assembly would be the easiest distribution.

But honestly, I'd have it be a customization feature. Last thing you want is to maintain everyone's logo changes due to: legal reasons, copywrite cases, whimsical artistic license, etc.

Which is short for.... have them provide a formatted image, and have them assign the company name during installation and store that off in the registry or in a meta file of some type (XML, manifest, etc.)

The best I can think of it a batch script.

Get your project to reference files (images (logo), text (company name), etc). ie C:\\MyProject\\Resources. So that when the project builds it complies them into the application/installer etc.

This way, you can write a script (.bat file) which copies in the resources needed per company.

Step 1 - Delete all files in the Resources folder

Step 2 - Use MSBuild.exe to build you project

Step 3 - Copy the files needed from the bin/release folder to a directory (ie C:\\Release\\CompanyA)

Step 4 - Change the variables in the script to load the details for the next company. And repeat from step 1, so it copies over the needed resource files and rebuilds.

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