{"id":323,"date":"2015-06-26T00:00:00","date_gmt":"2015-06-26T00:00:00","guid":{"rendered":"http:\/\/www.interventure.info\/iv-best-practices-automating-the-release-process-with-custom-msbuild-scripts\/"},"modified":"2021-04-14T13:59:35","modified_gmt":"2021-04-14T13:59:35","slug":"iv-best-practices-automating-the-release-process-with-custom-msbuild-scripts","status":"publish","type":"post","link":"https:\/\/www.interventure.info\/blog\/iv-best-practices-automating-the-release-process-with-custom-msbuild-scripts\/","title":{"rendered":"IV Best Practices: Automating the Release Process with custom MSBuild Scripts"},"content":{"rendered":"<p>In .NET world MSBuild is the build engine, the guy that transforms your code to binaries. Code is built by interpreting scripts and they hold a sequence of build steps. Usually, the only scripts that are used are project files, like csproj or vbproj files. On build server, you can specify a solution or project file to build. However, it can do much, much more if you use it with custom scripts.<\/p>\n<p>When starting the build, build server (TFS, TeamCity) passes a reference to your sln or csproj file to MSBuild. If you set it to pass the reference to another file, say &#8218;main.build&#8216;, MSBuild will try to interpret it as a build script.<\/p>\n<p>This script can have multiple custom build steps. These could include validation of properties which are passed to script or setting up folders for build output before the build itself.<\/p>\n<p>Regarding the build part, it can simply call another instance of MSBuild to build a solution or few of them and perhaps enforce a specific output directory. After the build script could have a step to run unit tests.<\/p>\n<p>If build and tests pass, script can create a release\/setup package by simply copying a set of files somewhere, by zipping them or by running a separate tool for making a setup (ClickOnce, InstallShield etc.). This can also include an obfuscation step for desktop applications.<\/p>\n<p>Script can run your setup package, install your service to IIS web server and\/or run scripts to setup database and actually create new environment. If needed, a set of integration tests using tools for automated testing (SoapUI) could be used to verify package as a whole.<\/p>\n<p>Automated cycle from build to deployment can greatly increase confidence in your code, both yours and your client&#8217;s. Hence you could come to a point where you automatically deploy to production environment if tests pass. This way you are going towards continuous delivery, an ideal of developers and clients.<\/p>\n<p>Many utility applications (testing frameworks, archiving utilities) support running through command line interface, which are great for running from MSBuild script. Also, many other functions like executing SQL script against a server, or setting up stuff on web\/application server are wrapped in tasks built by community. Finally, you can build you own tasks in C# or VB.NET for really special cases.<br \/>\nReferences:<br \/>\nhttps:\/\/www.soapui.org\/<br \/>\nhttps:\/\/www.msbuildextensionpack.com\/<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In .NET world MSBuild is the build engine, the guy that transforms your code to binaries. Code is built by interpreting scripts and they hold a sequence of build steps. Usually, the only scripts that are used are project files, like csproj or vbproj files. On build server, you can specify a solution or project [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":324,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[12],"tags":[],"class_list":["post-323","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-engineering"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.interventure.info\/de\/wp-json\/wp\/v2\/posts\/323","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.interventure.info\/de\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.interventure.info\/de\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.interventure.info\/de\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.interventure.info\/de\/wp-json\/wp\/v2\/comments?post=323"}],"version-history":[{"count":0,"href":"https:\/\/www.interventure.info\/de\/wp-json\/wp\/v2\/posts\/323\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.interventure.info\/de\/wp-json\/wp\/v2\/media\/324"}],"wp:attachment":[{"href":"https:\/\/www.interventure.info\/de\/wp-json\/wp\/v2\/media?parent=323"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.interventure.info\/de\/wp-json\/wp\/v2\/categories?post=323"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.interventure.info\/de\/wp-json\/wp\/v2\/tags?post=323"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}