<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="https://shazwazza.com/rss/xslt"?>
<rss xmlns:a10="http://www.w3.org/2005/Atom" version="2.0">
  <channel>
    <title>Shazwazza</title>
    <link>https://shazwazza.com/</link>
    <description>My blog which is pretty much just all about coding</description>
    <generator>Articulate, blogging built on Umbraco</generator>
    <image>
      <url>/media/0libq25y/frog.png?rmode=max&amp;v=1da0e911f4e6890</url>
      <title>Shazwazza</title>
      <link>https://shazwazza.com/</link>
    </image>
    <item>
      <guid isPermaLink="false">1171</guid>
      <link>https://shazwazza.com/post/appveyor-and-aspnet-core-previously-aspnet-5/</link>
      <category>ASP.Net</category>
      <title>AppVeyor and ASP.Net Core (Previously ASP.Net 5)</title>
      <description>&lt;p&gt;Last year I created a runtime Js/Css pre-processor for ASP.Net Core (Previously ASP.Net 5) called “&lt;a href="https://github.com/Shazwazza/Smidge" target="_blank"&gt;Smidge&lt;/a&gt;” and have been meaning to blog about how I integrated this with AppVeyor – to run my tests, build the project and output the Nuget files I need, so here it goes…&lt;/p&gt; &lt;h2&gt;The build script&lt;/h2&gt; &lt;p&gt;I use Powershell for my build scripts for my projects since it’s reasonably easy to read and the same script format has worked quite well for ASP.Net Core projects too. You can see the whole build file &lt;a href="https://github.com/Shazwazza/Smidge/blob/master/build.ps1" target="_blank"&gt;&lt;strong&gt;here&lt;/strong&gt;&lt;/a&gt;. Here’s the important things to note:&lt;/p&gt; &lt;p&gt;With AppVeyor (and probably other build servers), you need to ensure that it actually has the dnx version you need: &lt;/p&gt;&lt;pre class="csharpcode"&gt;# ensure the correct version
&amp;amp; $DNVM install 1.0.0-rc1-update1&lt;/pre&gt;
&lt;p&gt;Next you need to make sure that the current process is using the version you need to build:&lt;/p&gt;&lt;pre class="csharpcode"&gt;# use the correct version
&amp;amp; $DNVM use 1.0.0-rc1-update1&lt;/pre&gt;
&lt;p&gt;Then we need to use DNU to make sure that your project has everything it needs to build:&lt;/p&gt;&lt;pre class="csharpcode"&gt;&amp;amp; $DNU restore &lt;span class="str"&gt;"$ProjectJsonPath"&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;Lastly it’s just building and packaging the project:&lt;/p&gt;&lt;pre class="csharpcode"&gt;&amp;amp; $DNU build &lt;span class="str"&gt;"$ProjectJsonPath"&lt;/span&gt;
&amp;amp; $DNU pack &lt;span class="str"&gt;"$ProjectJsonPath"&lt;/span&gt; --configuration Release --&lt;span class="kwrd"&gt;out&lt;/span&gt; &lt;span class="str"&gt;"$ReleaseFolder"&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;The rest of the build file is normal Powershell bits. &lt;/p&gt;
&lt;h2&gt;The test script&lt;/h2&gt;
&lt;p&gt;I’m using xunit for unit tests in this project and similarly to the build script I’m using a simple Powershell script to execute the tests on the build server, the test runner file is &lt;a href="https://github.com/Shazwazza/Smidge/blob/master/tests.ps1" target="_blank"&gt;&lt;strong&gt;here&lt;/strong&gt;&lt;/a&gt;. The important parts are just like the above: Ensure the correct version is installed and being used by the current process and making sure that the project has everything it needs to build and finally to build it. The last missing piece is to actually run the tests:&lt;/p&gt;&lt;pre class="csharpcode"&gt;&amp;amp; $DNX -p &lt;span class="str"&gt;"$TestsFolder"&lt;/span&gt; test&lt;/pre&gt;
&lt;p&gt;Where ‘&lt;em&gt;test’&lt;/em&gt; is a command defined in my &lt;a href="https://github.com/Shazwazza/Smidge/blob/master/tests/Smidge.Tests/project.json#L10" target="_blank"&gt;project.json as part of my unit test project&lt;/a&gt;.&lt;/p&gt;
&lt;h2&gt;AppVeyor configuration&lt;/h2&gt;
&lt;p&gt;The good news is that there’s really not a lot to setup, it’s super easy. In your AppVeyor settings just go to the ‘Build’ section and tell it to execute the Powershell script with its build version information:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://shazwazza.com/media/articulate/windows-live-writer-smidge-rc3-released_eb4d-image_2.png"&gt;&lt;img title="image" style="display: inline" alt="image" src="http://shazwazza.com/media/articulate/windows-live-writer-smidge-rc3-released_eb4d-image_thumb.png" width="600" height="208"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Then for the unit tests is basically the same, click on the ‘Tests’ section and tell it to execute the Powershell test script:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://shazwazza.com/media/articulate/windows-live-writer-smidge-rc3-released_eb4d-image_4.png"&gt;&lt;img title="image" style="display: inline" alt="image" src="http://shazwazza.com/media/articulate/windows-live-writer-smidge-rc3-released_eb4d-image_thumb_1.png" width="600" height="222"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;And that’s pretty much it! The only other part I’ve had to setup is the paths to my Artifacts (Nuget files) based on the current build number.&lt;/p&gt;
&lt;p&gt;Now whenever I commit, AppVeyor will execute the build script and test script and we can see the output:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://shazwazza.com/media/articulate/windows-live-writer-smidge-rc3-released_eb4d-image_6.png"&gt;&lt;img title="image" style="display: inline" alt="image" src="http://shazwazza.com/media/articulate/windows-live-writer-smidge-rc3-released_eb4d-image_thumb_2.png" width="600" height="238"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;And it’s smart enough to know that the test runner executed is for unit tests, so all the unit test output shows up in the ‘Tests’ tab of the build&lt;/p&gt;
&lt;p&gt;&lt;a href="http://shazwazza.com/media/articulate/windows-live-writer-smidge-rc3-released_eb4d-image_8.png"&gt;&lt;img title="image" style="display: inline" alt="image" src="http://shazwazza.com/media/articulate/windows-live-writer-smidge-rc3-released_eb4d-image_thumb_3.png" width="600" height="152"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Now that that’s all setup, AppVeyor even gives you a handy Nuget feed that you can use to test your packages based on each build, this can be configured on the ‘NuGet’ settings section, for example here’s the Smidge feed: &lt;a title="https://ci.appveyor.com/nuget/smidge" href="https://ci.appveyor.com/nuget/smidge"&gt;https://ci.appveyor.com/nuget/smidge&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;Smidge 1.0.0-RC3&lt;/h2&gt;
&lt;p&gt;It’s worth noting that I’ve also released a new version of Smidge since I finally had some time to work on it. Couple of bugs fixed in this release and also a handy new feature too! You can see the release notes here: &lt;a title="https://github.com/Shazwazza/Smidge/releases/tag/1.0.0-rc3" href="https://github.com/Shazwazza/Smidge/releases/tag/1.0.0-rc3"&gt;https://github.com/Shazwazza/Smidge/releases/tag/1.0.0-rc3&lt;/a&gt;.&amp;nbsp; I’ve also updated a lot of the documentation, the main readme file was getting quite long so I’ve moved all of the docs over to the project’s Wiki on GitHub and condensed the readme for the most important bits. Have a look here: &lt;a title="https://github.com/Shazwazza/Smidge/releases/tag/1.0.0-rc3" href="https://github.com/Shazwazza/Smidge/releases/tag/1.0.0-rc3"&gt;https://github.com/Shazwazza/Smidge&lt;/a&gt;&lt;/p&gt;</description>
      <pubDate>Thu, 23 Mar 2023 15:08:15 Z</pubDate>
      <a10:updated>2023-03-23T15:08:15Z</a10:updated>
    </item>
  </channel>
</rss>