Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. MSBuild / Microsoft.Build... nyaaargh!

MSBuild / Microsoft.Build... nyaaargh!

Scheduled Pinned Locked Moved C#
helpvisual-studiodesignbeta-testingtools
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • W Offline
    W Offline
    Wenff
    wrote on last edited by
    #1

    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 :-)

    S 1 Reply Last reply
    0
    • W Wenff

      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 :-)

      S Offline
      S Offline
      SeMartens
      wrote on last edited by
      #2

      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.

      W 1 Reply Last reply
      0
      • S SeMartens

        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.

        W Offline
        W Offline
        Wenff
        wrote on last edited by
        #3

        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:

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups