I created a custom build task DLL that References Microsoft.Build.Utilities.dll
Since the file name is different in each version,
do I need to create separate project files to target different MSBuild versions? 2.0, 3.5, 4.0 / 4.5
I created a custom build task DLL that References Microsoft.Build.Utilities.dll
Since the file name is different in each version,
do I need to create separate project files to target different MSBuild versions? 2.0, 3.5, 4.0 / 4.5
I wouldn't do that. If you build your projects from the code, you should be able to set GlobalProperty
for every property you can find in .csproj file. The proper MSBuild version will be choosed automatically.
ProjectCollection pc = new ProjectCollection();
Dictionary<string, string> GlobalProperty = new Dictionary<string, string>();
//GlobalProperty.Add("Configuration", "Debug");
//GlobalProperty.Add("Platform", "x86");
//GlobalProperty.Add("OutputPath", "c:\\src");
//GlobalProperty.Add("TargetFrameworkVersion", "4.0");
BuildRequestData buidlRequest = new BuildRequestData("projectfile.csproj", GlobalProperty, null, new string[] { "Build" }, null);
BuildResult buildResult = BuildManager.DefaultBuildManager.Build(new BuildParameters(pc), buidlRequest);
//if (buildResult["Build"].ResultCode == TargetResultCode.Success)
//{
// Console.WriteLine("Build Success");
//}
//else
//{
// Console.WriteLine("Build Fail");
//}