MSBuild Project vs. PowerShell Build Procedure

I need to complete the following tasks:

  • Preconfiguration (loading dependencies, etc.)
  • Building a .net solution
  • Run Tests (unit tests and functional tests)
  • Documentation creation
  • Creating nuget packages
  • Display output

I can accomplish the task by creating a PS build routine (which only uses msbuild to compile the solution) or an MSBuild project with targets (which uses some PS helper scripts). PowerShell is more flexible, but MSBuild is a build framework that has some built-in build-related functionality. I'm wondering what the best approach would be. Please share your thoughts.

+3


source to share


2 answers


Out of the box, MSBuild specializes in handling tasks and their dependencies. So when you want to do custom things that MSBuild cannot do by default, you need to call scripts / tools through targets, or you can add more issue types including communities / custom extensions for your project.

Powershell , on the other hand, has no form, so you have to work without an inline structure, but you have the freedom to do what you want right out of the box, and without having to use another tool / language to fill in the blanks. For multiple projects, you need to create some kind of structure if you want your build system to be maintained.

If you want both worlds , PSAKE is a Task Handling Powershell Module that acts similar to MSBuild and has a RAKE based syntax which is pretty neat. In short, PSAKE has a lighter syntax than MSBuild and has most of its functionality available through Powershell, so you benefit from both worlds.



As a rule, this is a matter of taste and needs . I prefer a short and sweet syntax that says clearly which part of the code is doing something. MSBuild is XML based, so there is a lot of redundancy, it doesn't have an IDE that comes with it, and needs an external tool like Visual Studio to debug it. PSAKE is a Powershell module, so you can run PowerShell ISE, load the module, and enjoy IntelliSense while creating build scripts.

But understand that there are many options to choose from, so pick poison and don't narrow your choices to just MSBuild and Powershell . Check out some alternatives here.

+1


source


MSBuild (we now have a wrapper using dotnet cli) is Microsoft's build engine, its purpose is to create a set of tasks to finally get artifacts or builds. On the other hand, PowerShell is all about task automation and configuration management. This means you can script more complex pipelines, including Calling MSBuild, NuGet CLI, etc. (For example, call remote modules or any other additional tasks).



0


source







All Articles