Programmatically Update Visual Studio Solution and Project Files

I have many visual studio projects that are delivered to the client using the installer. After installation, all project files and solutions must have the latest installed visual studio version. Is there a way to convert many projects quickly ?

I tried the following:

1) parsing files and replacing various properties such as ToolsVersion , etc. It is fast but not reliable and needs to be changed for every new Visual Studio that enters the market (annually with AFAIK)

2) Using the evvenv update function, reliably, but VERY slowly:

 string[] files = Directory.GetFiles(@"c:\MyTmp", "*.sln", SearchOption.AllDirectories); foreach (string file in files) { Process process = new Process(); process.StartInfo.FileName = pathToTheLatestVS; process.StartInfo.Arguments = "/Upgrade \"" + file + "\""; process.Start(); process.WaitForExit(); } 

3) I tried to create a hidden instance of VS and manipulate the solutions there, as described here , but with no luck.

Thus, you can quickly and reliably upgrade many project / solution files to a specific version of Visual Studio?

+6
source share
1 answer

Let me give you a different view than what you presented 2. The fact that the update is slow is that all kinds of checks are performed on the projects / solutions that you are trying to update. To receive feedback on these checks, an “Update Report” is created. This is information that cannot be ignored, because it provides remedies for these issues.

You declare that you deploy projects / solutions through the installer. Assuming you have a development team / tools that are relevant, you can perform updates as part of the design / development of your installer. Why don't you perform the updates yourself and not include project files in your installer. During installation, you must install the version of the project / solution files that correspond to the target platform.

+2
source

Source: https://habr.com/ru/post/947101/


All Articles