{"id":191,"date":"2013-12-06T13:00:54","date_gmt":"2013-12-06T13:00:54","guid":{"rendered":"http:\/\/writeasync.net\/?p=191"},"modified":"2013-11-26T17:20:18","modified_gmt":"2013-11-26T17:20:18","slug":"initialize-projects-script","status":"publish","type":"post","link":"http:\/\/writeasync.net\/?p=191","title":{"rendered":"Initialize projects script"},"content":{"rendered":"<p>I have a preferred Visual Studio solution layout. It is basically as follows, using <em>MyProj<\/em> as a sample name:<\/p>\n<ul>\n<li><strong><em>MyProj<\/em><\/strong>: Solution root.\n<ul>\n<li><strong>bin<\/strong>: <em>All<\/em> built binaries go here.<\/li>\n<li><strong>external<\/strong>: External binary dependencies (e.g. unit test runners).<\/li>\n<li><strong>source<\/strong>: Root of source code projects.\n<ul>\n<li><strong><em>MyProj<\/em>.App<\/strong>: Console application.<\/li>\n<li><strong><em>MyProj<\/em>.Core<\/strong>: Core library.<\/li>\n<\/ul>\n<\/li>\n<li><strong>test<\/strong>: Root of test code projects.\n<ul>\n<li><strong><em>MyProj<\/em>.Test.Unit<\/strong>: Unit test library.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>I have initialized enough project layouts manually that I felt the need to write a PowerShell script to save on future effort. Perhaps you have a use for it as well?<\/p>\n<h2>Get the script here: <a title=\"InitProjects script\" href=\"https:\/\/github.com\/brian-dot-net\/writeasync\/blob\/master\/scripts\/InitProjects.cmd\">InitProjects.cmd<\/a><\/h2>\n<p>The script generates a layout as above with solution and project files compatible with <a title=\"Visual Studio Downloads\" href=\"http:\/\/www.visualstudio.com\/downloads\/download-visual-studio-vs\">Visual Studio [Express] 2013<\/a>. It automatically creates a <a title=\"StyleCop\" href=\"http:\/\/stylecop.codeplex.com\/\">StyleCop<\/a> settings file with my preferred rule set and copies over <a title=\"xUnit.net\" href=\"http:\/\/xunit.codeplex.com\/\">xUnit.net<\/a> dependencies for unit testing.<\/p>\n<p>Example usage and output:<\/p>\n<p><code><br \/>\n<strong>&gt; InitProjects.cmd D:\\Temp\\z MyProj MyCompany %public%\\Programs\\xUnit.net<\/strong><br \/>\nPreparing project 'MyProj.App'...<br \/>\nWriting file 'D:\\Temp\\z\\MyProj\\source\\MyProj.App\\MyProj.App.csproj'...<br \/>\nWriting file 'D:\\Temp\\z\\MyProj\\source\\MyProj.App\\Program.cs'...<br \/>\nWriting file 'D:\\Temp\\z\\MyProj\\source\\MyProj.App\\Properties\\AssemblyInfo.cs'...<br \/>\nPreparing project 'MyProj.Core'...<br \/>\nWriting file 'D:\\Temp\\z\\MyProj\\source\\MyProj.Core\\MyProj.Core.csproj'...<br \/>\nWriting file 'D:\\Temp\\z\\MyProj\\source\\MyProj.Core\\Class1.cs'...<br \/>\nWriting file 'D:\\Temp\\z\\MyProj\\source\\MyProj.Core\\Properties\\AssemblyInfo.cs'...<br \/>\nPreparing project 'MyProj.Test.Unit'...<br \/>\nWriting file 'D:\\Temp\\z\\MyProj\\test\\MyProj.Test.Unit\\MyProj.Test.Unit.csproj'...<br \/>\nWriting file 'D:\\Temp\\z\\MyProj\\test\\MyProj.Test.Unit\\Test1.cs'...<br \/>\nWriting file 'D:\\Temp\\z\\MyProj\\test\\MyProj.Test.Unit\\Properties\\AssemblyInfo.cs'...<br \/>\nPreparing StyleCop settings file...<br \/>\nWriting file 'D:\\Temp\\z\\MyProj\\StyleCop.settings'...<br \/>\nPreparing solution file...<br \/>\nWriting file 'D:\\Temp\\z\\MyProj\\MyProj.sln'...<br \/>\nCopying xUnit.net dependencies from 'C:\\Users\\Public\\Programs\\xUnit.net' to 'D:\\Temp\\z\\MyProj\\external\\xUnit.net'...<br \/>\n<\/code><\/p>\n<p>To ensure everything worked correctly, open MyProj.sln in Visual Studio and compile it. You should see output like the following:<br \/>\n<code><br \/>\n1&gt;------ Build started: Project: MyProj.Core, Configuration: Debug Any CPU ------<br \/>\n1&gt; MyProj.Core -&gt; D:\\temp\\z\\MyProj\\bin\\Debug\\MyProj.Core.dll<br \/>\n2&gt;------ Build started: Project: MyProj.App, Configuration: Debug Any CPU ------<br \/>\n3&gt;------ Build started: Project: MyProj.Test.Unit, Configuration: Debug Any CPU ------<br \/>\n2&gt; MyProj.App -&gt; D:\\temp\\z\\MyProj\\bin\\Debug\\MyProj.App.exe<br \/>\n3&gt; MyProj.Test.Unit -&gt; D:\\temp\\z\\MyProj\\bin\\Debug\\MyProj.Test.Unit.dll<br \/>\n3&gt; xUnit.net MSBuild runner (32-bit .NET 4.0.30319.18408)<br \/>\n3&gt; xunit.dll: Version 1.9.2.1705<br \/>\n3&gt; Test assembly: D:\\temp\\z\\MyProj\\bin\\Debug\\MyProj.Test.Unit.dll<br \/>\n3&gt; Tests: 1, Failures: 0, Skipped: 0, Time: 0.127 seconds<br \/>\n========== Build: 3 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========<br \/>\n<\/code><br \/>\nNote that StyleCop and xUnit.net run automatically on each build. This means that <strong>StyleCop errors and xUnit.net unit test failures will break the build<\/strong> &#8212; just the way I like it!<\/p>\n<p>To ensure the binaries were built correctly, &#8220;Start without debugging&#8221; (default shortcut <kbd>Ctrl+F5<\/kbd>) and you should observe the following output:<br \/>\n<code><br \/>\nHello, world!<br \/>\nPress any key to continue . . .<br \/>\n<\/code><br \/>\nEnjoy your newfound productivity!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I have a preferred Visual Studio solution layout. It is basically as follows, using MyProj as a sample name: MyProj: Solution root. bin: All built binaries go here. external: External binary dependencies (e.g. unit test runners). source: Root of source&hellip; <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[31],"tags":[],"class_list":["post-191","post","type-post","status-publish","format-standard","hentry","category-scripts"],"_links":{"self":[{"href":"http:\/\/writeasync.net\/index.php?rest_route=\/wp\/v2\/posts\/191","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/writeasync.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/writeasync.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/writeasync.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/writeasync.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=191"}],"version-history":[{"count":0,"href":"http:\/\/writeasync.net\/index.php?rest_route=\/wp\/v2\/posts\/191\/revisions"}],"wp:attachment":[{"href":"http:\/\/writeasync.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=191"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/writeasync.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=191"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/writeasync.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=191"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}