简体   繁体   中英

Combining between two csproj files safely

I have two very long and detailed .csproj files. I want to combine them into one.

I used text comparer but the items are not in the same order and it's hard to isolate differences.

How would you recommend to combine them? (they have compile, include, post build and after build events)

edit: I want to merge 2 unrelated projects with some common dependencies

Copy the files from project 1 into the project 2 folder. Then turn on "Show all files" so you can see the files that aren't in the project. Then right-click each file and choose "Include in project".

I would probably do most of this in Visual Studio. You can either drag the files you need from one project to the other, or you can copy all the files from one project folder to the other in the file system and turn on "show all files" in the solution explorer to show which need to be added. You will then need to align the namespaces. The Class View window can help identify types which do not fall inside the right namespace. A refactoring tool like Resharper can also help fix up the namespaces.

If you have explicit pre or post build events in each project, I would use the VS GUI to show these and manually combine. If you have custom build targets/tasks in the files, I would isolate these in a good text/XML editor and manually union them as required.

The other thing you will have to do is to add references to the final project which it did not originally require but were required by the other project. It should be quite quick to identify which references need to be added, by attempting compilation and inspecting any errors.

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