Hi,
I currently have a need to programmatically add an existing file to a project. To do this, I have referenced Microsoft.Build (4.0) from my 4.5 project. I then use the following code to load the project:
var project = new Project("<path to csproj file>");
When I run it I'm getting the following error:
System.TypeInitializationException: The type initializer for 'SelfServiceNuGetInstaller.SolutionHelper' threw an
exception. ---> Microsoft.Build.Exceptions.InvalidProjectFileException: The imported project "C:\Program Files
(x86)\MSBuild\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" was not found. Confirm
that the path in the <Import> declaration is correct, and that the file exists on disk.
I should note that I am using VS13 and do not have any other version installed. I believe the Microsoft.Build DLL is looking for an older version of VS that I don't have installed. I might be able to correct this by locating and updating an Environment Variable, but I plan on running this code in a nuget package so I don't want the user to have to do that.
Does anyone know if there is a way to tell the Build DLL where the correct VisualStudio "vX" folder is?
TIA,
Matt
There is indeed a harmony to the universe.