MSBuild / Microsoft.Build... nyaaargh!
-
Someone out there must be able to help me... I'm trying to find/design a way of automating my project's builds, publishing, versioning in VSS etc and I'd like to create an app/script that will obey my command and do in one easy button click, what would otherwise take copious amounts of time & attention. The general idea is: Build a project/solution based on the .*proj files, publish the project with different config settings & install location depending on whether the app is going to QA, Pre-Prod or Production. I would also like to be able to have Source Safe's labelling done automatically. So far, I have found that Microsoft's MSBuild Reference on MSDN is virtually useless ( :wtf: ???), but I have been able to compile a project via the command line using it. I found that Microsoft.Build.BuildEngine looked perfect for what I'm trying to acheive, however, using the following code, I can't get it to build the project:
Engine engine = new Engine();
Project project = new Project(engine);
project.Load(strProjFile);
project.Build();The Build method on the Project keeps returning False - no error, nothing. (Before you ask, yes, the path to the project file is correct - the same file builds fine through VS2008 as well as MSBuild) (Oh, and again, Great Job Microsoft on the crummy documentation) If anyone has an idea of where I am going wrong, please, please, please! Let me know :-)
-
Someone out there must be able to help me... I'm trying to find/design a way of automating my project's builds, publishing, versioning in VSS etc and I'd like to create an app/script that will obey my command and do in one easy button click, what would otherwise take copious amounts of time & attention. The general idea is: Build a project/solution based on the .*proj files, publish the project with different config settings & install location depending on whether the app is going to QA, Pre-Prod or Production. I would also like to be able to have Source Safe's labelling done automatically. So far, I have found that Microsoft's MSBuild Reference on MSDN is virtually useless ( :wtf: ???), but I have been able to compile a project via the command line using it. I found that Microsoft.Build.BuildEngine looked perfect for what I'm trying to acheive, however, using the following code, I can't get it to build the project:
Engine engine = new Engine();
Project project = new Project(engine);
project.Load(strProjFile);
project.Build();The Build method on the Project keeps returning False - no error, nothing. (Before you ask, yes, the path to the project file is correct - the same file builds fine through VS2008 as well as MSBuild) (Oh, and again, Great Job Microsoft on the crummy documentation) If anyone has an idea of where I am going wrong, please, please, please! Let me know :-)
Do you try to build a Continous Integration system? I would suggest using CruiseControl.NET. We accomplished that on a check-in to VSS the projects are compiled, unit-tests will run, documentation and release notes generated and at least a msi-file will be created. Regards Sebastian
It's not a bug, it's a feature! Check out my CodeProject article Permission-by-aspect. Me in Softwareland.
-
Do you try to build a Continous Integration system? I would suggest using CruiseControl.NET. We accomplished that on a check-in to VSS the projects are compiled, unit-tests will run, documentation and release notes generated and at least a msi-file will be created. Regards Sebastian
It's not a bug, it's a feature! Check out my CodeProject article Permission-by-aspect. Me in Softwareland.
Hah! Victory :-D It appears that if you add logging, you find out what the problem is...
// Instantiate a new Engine object Engine engine = new Engine(); // Instantiate a new FileLogger to generate build log FileLogger logger = new FileLogger(); // Set the logfile parameter to indicate the log destination logger.Parameters = @"logfile=" + strlogFile; // Register the logger with the engine engine.RegisterLogger(logger); // Build a project file bool success = engine.BuildProjectFile(strProjectFile); //Unregister all loggers to close the log file engine.UnregisterAllLoggers(); if (success) MessageBox.Show("Build succeeded."); else MessageBox.Show(@"Build failed. View " + strLogFile + " for details");
Using the above code, I was able to view the log of the issue: C:\WINDOWS\Microsoft.NET\Framework\v3.5\Microsoft.WinFX.targets(64,7): error MSB4127: The "GetWinFXPath" task could not be instantiated from the assembly "PresentationBuildTasks, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35". This issue in turn needs the following config file settings to be added:
<configuration>
<configSections>
<section name="msbuildToolsets" type="Microsoft.Build.BuildEngine.ToolsetConfigurationSection, Microsoft.Build.Engine, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</configSections>
<startup>
<supportedRuntime version="v2.0.50727" safemode="true"/>
<requiredRuntime version="v2.0.50727" safemode="true"/>
</startup>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Microsoft.Build.Framework" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-99.9.9.9" newVersion="3.5.0.0"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
<!-- To define one or more new toolsets, add an 'msbuildToolsets' element in this file. -->
</configuration>My project builds! :cool: