code_junkie

How to run MSBuild from Powershell without spawning msbuild.exe process

Nov 13th, 2011
338
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. [void][System.Reflection.Assembly]::Load('Microsoft.Build.Engine, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a')
  2. [void][Microsoft.Build.BuildEngine.Engine]::GlobalEngine.BuildProjectFile("path/main.proj")
  3.  
  4. [void][System.Reflection.Assembly]::Load('Microsoft.Build.Engine, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a')
  5. $engine = New-Object Microsoft.Build.BuildEngine.Engine
  6. $engine.RegisterLogger((New-Object Microsoft.Build.BuildEngine.ConsoleLogger))
  7. $engine.BuildProjectFile('fullPathsome.proj')
  8.  
  9. 'MSBUILD : warning MSB4056: The MSBuild engine must be called on
  10. a single-threaded-apartment. Current threading model is "MTA".
  11. Proceeding, but some tasks may not function correctly.'
  12.  
  13. [void][System.Reflection.Assembly]::Load('Microsoft.Build.Utilities.v3.5, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a')
  14. $msbuild = [Microsoft.Build.Utilities.ToolLocationHelper]::GetPathToDotNetFrameworkFile("msbuild.exe", "VersionLatest")
  15. &$msbuild fullPathsome.proj
  16.  
  17. Microsoft.Build.Framework
  18.  
  19. Microsoft.Build.BuildEngine
Add Comment
Please, Sign In to add comment