<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
        <title>Code Inside Blog</title>
        <description>Code Inside Blog - Code Inside Team</description>
        <link>https://blog.codeinside.eu</link>
        <link>https://blog.codeinside.eu</link>
        <lastBuildDate>Mon, 02 Jan 2017 22:37:31 +0000</lastBuildDate>
        <pubDate>Mon, 02 Jan 2017 22:37:31 +0000</pubDate>
        <ttl>1800</ttl>


        <item>
                <title>GitHub API: Create or update files</title>
                <description>
&lt;p&gt;This blogpost covers a pretty basic GitHub topic: Creating and updating content on GitHub. Of course, there are many ways to do it - e.g. you could do the full Git-ceremony and it would work with all Git hosts, but in my case I just wanted to target the &lt;a href=&quot;https://developer.github.com/v3/&quot;&gt;&lt;strong&gt;offical GitHub API&lt;/strong&gt;&lt;/a&gt;.&lt;/p&gt;

&lt;h2 id=&quot;prerequisite-a-github-user-repo-and-token&quot;&gt;Prerequisite: A GitHub User, Repo and Token&lt;/h2&gt;

&lt;p&gt;To use this code you will need write access to a GitHub repository and you should have a valid &lt;a href=&quot;https://github.com/settings/tokens&quot;&gt;GitHub token&lt;/a&gt;.&lt;/p&gt;

&lt;h2 id=&quot;code&quot;&gt;Code&lt;/h2&gt;

&lt;p&gt;The most simple way to communicate with the &lt;a href=&quot;https://developer.github.com/v3/&quot;&gt;GitHub API&lt;/a&gt; is by using the &lt;a href=&quot;https://www.nuget.org/packages/Octokit/&quot;&gt;Octokit SDK&lt;/a&gt; (from GitHub).&lt;/p&gt;

&lt;p&gt;Description:
Inside the try-block we try to &lt;a href=&quot;https://developer.github.com/v3/repos/contents/#get-contents&quot;&gt;get the target file&lt;/a&gt;, if it is already committed in the repo the API will return the last commit SHA.&lt;/p&gt;

&lt;p&gt;With this SHA it is possible to &lt;a href=&quot;https://developer.github.com/v3/repos/contents/#update-a-file&quot;&gt;create a new commit to do the actual update&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;If the file was not found, &lt;a href=&quot;https://developer.github.com/v3/repos/contents/#create-a-file&quot;&gt;we create the file&lt;/a&gt;. I’m not a huge fan of this try/catch block, but didn’t found any other way to check if the file is comitted or not (please give me a hint if this is wrong ;))&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Octokit;

namespace CreateOrUpdateGitHubFile
{
    class Program
    {
        static void Main(string[] args)
        {
            Task.Run(async () =&amp;gt;
            {
                var ghClient = new GitHubClient(new ProductHeaderValue(&quot;Octokit-Test&quot;));
                ghClient.Credentials = new Credentials(&quot;ACCESS-TOKEN&quot;);

                // github variables
                var owner = &quot;OWNER&quot;;
                var repo = &quot;REPO&quot;;
                var branch = &quot;BRANCH&quot;;

                var targetFile = &quot;_data/test.txt&quot;;

                try
                {
                    // try to get the file (and with the file the last commit sha)
                    var existingFile = await ghClient.Repository.Content.GetAllContentsByRef(owner, repo, targetFile, branch);

                    // update the file
                    var updateChangeSet = await ghClient.Repository.Content.UpdateFile(owner, repo, targetFile,
                       new UpdateFileRequest(&quot;API File update&quot;, &quot;Hello Universe! &quot; + DateTime.UtcNow, existingFile.First().Sha, branch));
                }
                catch (Octokit.NotFoundException)
                {
                    // if file is not found, create it
                    var createChangeSet = await ghClient.Repository.Content.CreateFile(owner,repo, targetFile, new CreateFileRequest(&quot;API File creation&quot;, &quot;Hello Universe! &quot; + DateTime.UtcNow, branch));
                }

                
                
            }).Wait();
        }
    }
}
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;The demo code is also available on &lt;a href=&quot;https://github.com/Code-Inside/Samples/tree/master/2017/CreateOrUpdateGitHubFile&quot;&gt;&lt;strong&gt;GitHub&lt;/strong&gt;&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Hope this helps.&lt;/p&gt;
</description>
                <link>https://blog.codeinside.eu/2017/01/02/create-or-update-files-via-the-github-api/</link>
                <guid>https://blog.codeinside.eu/2017/01/02/create-or-update-files-via-the-github-api</guid>
                <pubDate>Mon, 02 Jan 2017 23:45:00 +0000</pubDate>
        </item>

        <item>
                <title>DbProviderFactories: Write database agnostic ADO.NET code</title>
                <description>
&lt;p&gt;Recently I needed to write a module that needs to connect to a wide range of SQL-DBs, e.g. MySQL, MS SQL, Oracle etc.&lt;/p&gt;

&lt;h2 id=&quot;problem-most-providers-will-use-their-concret-classes&quot;&gt;Problem: Most providers will use their concret classes&lt;/h2&gt;

&lt;p&gt;If you look at the C# example on the &lt;a href=&quot;https://dev.mysql.com/doc/connector-net/en/connector-net-programming-connecting-open.html&quot;&gt;MySQL dev page&lt;/a&gt; you will see the MsSql-Namespace and classes:&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;MySql.Data.MySqlClient.MySqlConnection conn;
string myConnectionString;

myConnectionString = &quot;server=127.0.0.1;uid=root;&quot; +
    &quot;pwd=12345;database=test;&quot;;

try
{
    conn = new MySql.Data.MySqlClient.MySqlConnection();
    conn.ConnectionString = myConnectionString;
    conn.Open();
}
catch (MySql.Data.MySqlClient.MySqlException ex)
{
    MessageBox.Show(ex.Message);
}
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;The same classes will probably not work for a MS SQL database.&lt;/p&gt;

&lt;h2 id=&quot;solution-use-the-dbproviderfactories&quot;&gt;“Solution”: Use the DbProviderFactories&lt;/h2&gt;

&lt;p&gt;For example if you install the &lt;a href=&quot;https://www.nuget.org/packages/MySql.Data&quot;&gt;MySql-NuGet package&lt;/a&gt; you will also get this little enhancement to you app.config:&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&amp;lt;system.data&amp;gt;
  &amp;lt;DbProviderFactories&amp;gt;
    &amp;lt;remove invariant=&quot;MySql.Data.MySqlClient&quot; /&amp;gt;
    &amp;lt;add name=&quot;MySQL Data Provider&quot; invariant=&quot;MySql.Data.MySqlClient&quot; description=&quot;.Net Framework Data Provider for MySQL&quot; type=&quot;MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data, Version=6.9.9.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d&quot; /&amp;gt;
  &amp;lt;/DbProviderFactories&amp;gt;
&amp;lt;/system.data&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Now we can get a reference to the MySql client via the DbProviderFactories:&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;using System;
using System.Data;
using System.Data.Common;

namespace DbProviderFactoryStuff
{
    class Program
    {
        static void Main(string[] args)
        {
            try
            {
                Console.WriteLine(&quot;All registered DbProviderFactories:&quot;);
                var allFactoryClasses = DbProviderFactories.GetFactoryClasses();

                foreach (DataRow row in allFactoryClasses.Rows)
                {
                    Console.WriteLine(row[0] + &quot;: &quot; + row[2]);
                }

                Console.WriteLine();
                Console.WriteLine(&quot;Try to access a MySql DB:&quot;);

                DbProviderFactory dbf = DbProviderFactories.GetFactory(&quot;MySql.Data.MySqlClient&quot;);
                using (DbConnection dbcn = dbf.CreateConnection())
                {
                    dbcn.ConnectionString = &quot;Server=localhost;Database=testdb;Uid=root;Pwd=Pass1word;&quot;;
                    dbcn.Open();
                    using (DbCommand dbcmd = dbcn.CreateCommand())
                    {
                        dbcmd.CommandType = CommandType.Text;
                        dbcmd.CommandText = &quot;SHOW TABLES;&quot;;

                        // parameter...
                        //var foo = dbcmd.CreateParameter();
                        //foo.ParameterName = &quot;...&quot;;
                        //foo.Value = &quot;...&quot;;

                        using (DbDataReader dbrdr = dbcmd.ExecuteReader())
                        {
                            while (dbrdr.Read())
                            {
                                Console.WriteLine(dbrdr[0]);
                            }
                        }
                    }
                }
            }
            catch (Exception exc)
            {
                Console.WriteLine(exc.Message);
            }

            Console.ReadLine();

        }
    }
}
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;The most important line is this one:&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;DbProviderFactory dbf = DbProviderFactories.GetFactory(&quot;MySql.Data.MySqlClient&quot;);
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Now with the &lt;a href=&quot;https://msdn.microsoft.com/en-us/library/system.data.common.dbproviderfactory(v=vs.110).aspx&quot;&gt;&lt;strong&gt;DbProviderFactory&lt;/strong&gt;&lt;/a&gt; from the MySql client we can access the MySql database without using any MySql-specific classes.&lt;/p&gt;

&lt;p&gt;There are a couple of “in-built” db providers registered, like the MS SQL provider or ODBC stuff.&lt;/p&gt;

&lt;p&gt;The above code will output something like this:&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;All registered DbProviderFactories:
Odbc Data Provider: System.Data.Odbc
OleDb Data Provider: System.Data.OleDb
OracleClient Data Provider: System.Data.OracleClient
SqlClient Data Provider: System.Data.SqlClient
Microsoft SQL Server Compact Data Provider 4.0: System.Data.SqlServerCe.4.0
MySQL Data Provider: MySql.Data.MySqlClient
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;h2 id=&quot;other-solutions&quot;&gt;Other solutions&lt;/h2&gt;

&lt;p&gt;Of course there are other solutions - some OR-Mapper like the EntityFramework have a provider model which might also work, but this one here is a pretty basic approach.&lt;/p&gt;

&lt;h2 id=&quot;sql-commands&quot;&gt;SQL Commands&lt;/h2&gt;

&lt;p&gt;The tricky bit here is that you need to make sure that your SQL commands work on your database - this is &lt;strong&gt;not a silver bullet&lt;/strong&gt;, it &lt;strong&gt;just lets you connect and execute SQL commands to any ‘registered’ database&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;The full demo code is also available on &lt;a href=&quot;https://github.com/Code-Inside/Samples/tree/master/2016/DbProviderFactoryStuff&quot;&gt;&lt;strong&gt;GitHub&lt;/strong&gt;&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Hope this helps.&lt;/p&gt;
</description>
                <link>https://blog.codeinside.eu/2016/12/31/dbproviderfactory-write-database-agnostic-adonet-code/</link>
                <guid>https://blog.codeinside.eu/2016/12/31/dbproviderfactory-write-database-agnostic-adonet-code</guid>
                <pubDate>Sat, 31 Dec 2016 14:00:00 +0000</pubDate>
        </item>

        <item>
                <title>Enable SSL with custom domains on GitHub Pages via Cloudflare</title>
                <description>
&lt;p&gt;Two weeks ago I decided (finally!) that I should enable SSL on this blog.&lt;/p&gt;

&lt;h2 id=&quot;problem-github-pages-with-a-custom-domain&quot;&gt;Problem: GitHub Pages with a custom domain&lt;/h2&gt;

&lt;p&gt;This blog is hosted on GitHub Pages with a custom domain, which currently doesn’t support SSL out of the box. If you stick with a github.io domain SSL is not a problem.&lt;/p&gt;

&lt;h2 id=&quot;cloudflare-to-the-rescure&quot;&gt;Cloudflare to the rescure&lt;/h2&gt;

&lt;p&gt;I decided to take a deeper look at &lt;strong&gt;&lt;a href=&quot;https://www.cloudflare.com&quot;&gt;Cloudflare&lt;/a&gt;&lt;/strong&gt;, which provides DNS, CDN and other “network”-related services. For the “main” service Cloudflare serves as the DNS for your domain and is like a proxy.&lt;/p&gt;

&lt;p&gt;With this setup you have some nice benefits:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;A free SSL certificate (AFAIK you can also use your own cert if you need)&lt;/li&gt;
  &lt;li&gt;A CDN cache&lt;/li&gt;
  &lt;li&gt;DDOS protection&lt;/li&gt;
  &lt;li&gt;“Analytics”&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Be aware: This is just the &lt;strong&gt;free plan&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;And everything is pretty easy to manage via the web interface.&lt;/p&gt;

&lt;h3 id=&quot;setup&quot;&gt;Setup&lt;/h3&gt;

&lt;p&gt;The first step is to register at Cloudflare &amp;amp; setup your domain. After the first step you need to change the name server for your domain to Cloudflares server.&lt;/p&gt;

&lt;p&gt;All your domain belonging can now be managed inside Cloudflare:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://blog.codeinside.eu/assets/md-images/2016-11-14/dns.png&quot; alt=&quot;x&quot; title=&quot;DNS&quot; /&gt;&lt;/p&gt;

&lt;h3 id=&quot;setting-up-some-rules&quot;&gt;Setting up some rules&lt;/h3&gt;

&lt;p&gt;When your DNS changes are done (which can take a couple of hours) you might want to introduce some basic rules. I use these settings, which enforces HTTPS and Cloudflare cache:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://blog.codeinside.eu/assets/md-images/2016-11-14/rules.png&quot; alt=&quot;x&quot; title=&quot;Rules&quot; /&gt;&lt;/p&gt;

&lt;h3 id=&quot;done-or-nearly-done&quot;&gt;Done… or nearly done.&lt;/h3&gt;

&lt;p&gt;Now we have done the “Cloudflare-part”. The next step is to make sure that everything on your page uses HTTPS instead of HTTP to avoid “mixed content”-errors.&lt;/p&gt;

&lt;p&gt;Some notes from my own “migration”:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;If you have Google Analytics - make sure you change the property-settings to the HTTPS URL&lt;/li&gt;
  &lt;li&gt;If you use Disqus you &lt;strong&gt;need&lt;/strong&gt; to migrate your comments from the HTTP url to the HTTPS URL. There is a migrate tool available, which uses a CSV file.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;other-solutions&quot;&gt;Other solutions…&lt;/h2&gt;

&lt;p&gt;As far as I know there are other, similar, providers out there and of course you can host the page yourself.&lt;/p&gt;

&lt;p&gt;Cloudflare is an easy solution if you are willing to hand of the DNS settings of your domain.&lt;/p&gt;

&lt;p&gt;Hope this helps!&lt;/p&gt;
</description>
                <link>https://blog.codeinside.eu/2016/11/14/ssl-with-custom-domains-on-gh-pages-via-cloudflare/</link>
                <guid>https://blog.codeinside.eu/2016/11/14/ssl-with-custom-domains-on-gh-pages-via-cloudflare</guid>
                <pubDate>Mon, 14 Nov 2016 23:15:00 +0000</pubDate>
        </item>

        <item>
                <title>Writing loops in T-SQL</title>
                <description>
&lt;p&gt;The topic is quite old, but I found it really helpful, so be warned.&lt;/p&gt;

&lt;h2 id=&quot;scenario-iterate-over-a-result-set-and-insert-it-in-a-new-table-in-t-sql&quot;&gt;Scenario: Iterate over a result set and insert it in a new table in T-SQL&lt;/h2&gt;

&lt;p&gt;I had to write a SQL migration script to move date from an old table into a new table with a new primary key.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Update! I discovered that my problem would have been solved with a much simpler SQL script (INSERT INTO x …(SELECT … FROM Y)). So my example here is pretty dumb - sorry if this confuses you, but I will keep the blogpost to show the mechanics. Thanks Mark!&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Here was/is my resulting script using &lt;strong&gt;&lt;a href=&quot;https://msdn.microsoft.com/en-us/library/ms180169.aspx&quot;&gt;T-SQL Cursors&lt;/a&gt;&lt;/strong&gt;:&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;DECLARE @TemplateId as uniqueidentifier;
DECLARE @UserId as uniqueidentifier;

DECLARE @OldTemplateFavCursor as CURSOR;

SET @OldTemplateFavCursor = CURSOR FOR
SELECT UserTemplate.[Template_Id], UserTemplate.[User_Id] FROM UserTemplate;
 
OPEN @OldTemplateFavCursor;
FETCH NEXT FROM @OldTemplateFavCursor INTO @TemplateId, @UserId;
 
WHILE @@FETCH_STATUS = 0
BEGIN
 INSERT INTO dbo.[UserFavoriteTemplate]
           ([Id]
           ,[TemplateId]
           ,[UserId])
     VALUES
           (NEWID()
           ,@TemplateId
           ,@UserId)

FETCH NEXT FROM @OldTemplateFavCursor INTO @TemplateId, @UserId;
END
 
CLOSE @OldTemplateFavCursor;
DEALLOCATE @OldTemplateFavCursor;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;h2 id=&quot;explanation&quot;&gt;Explanation&lt;/h2&gt;

&lt;p&gt;In the first couple of lines we just declare some variables.&lt;/p&gt;

&lt;p&gt;In this particular script we want to move the “TemplateId” &amp;amp; “UserId” from the table “UserTemplate” into the target table “UserFavoriteTemplate”, but I also want to store an additional GUID as Id.&lt;/p&gt;

&lt;p&gt;This line will select our current data into the cursor:&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;SET @OldTemplateFavCursor = CURSOR FOR SELECT UserTemplate.[Template_Id], UserTemplate.[User_Id] FROM UserTemplate;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;With the “OPEN”, “FETCH NEXT” and “CLOSE” we move the cursor and inside the “WHILE” we can do our migration.&lt;/p&gt;

&lt;p&gt;The syntax seems (from a C# perspective) strange, but works well for this scenario.&lt;/p&gt;

&lt;h2 id=&quot;performance-consideration&quot;&gt;Performance consideration&lt;/h2&gt;

&lt;p&gt;I wouldn’t recommend this approach for large scale migrations or actual production code because I heard that the performance is not as great as some clever joins or other T-SQL magic.&lt;/p&gt;

&lt;h2 id=&quot;make-sure-you-really-need-this&quot;&gt;Make sure you really need this&lt;/h2&gt;

&lt;p&gt;You can do some clever joins with SQL - make sure you really need this approach. My example here is not a clever one, so use this feature wisely. (again - thanks to Mark for the comment!)&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Thanks Christopher for your help!&lt;/strong&gt;&lt;/p&gt;
</description>
                <link>https://blog.codeinside.eu/2016/10/31/loops-in-tsql/</link>
                <guid>https://blog.codeinside.eu/2016/10/31/loops-in-tsql</guid>
                <pubDate>Mon, 31 Oct 2016 22:15:00 +0000</pubDate>
        </item>

        <item>
                <title>Lets convert a WPF app to the Universal Windows Platform</title>
                <description>
&lt;h2 id=&quot;project-centennial---running-desktop-apps-in-the-uwp-world&quot;&gt;Project Centennial - running desktop apps in the UWP world&lt;/h2&gt;

&lt;p&gt;Last year Microsoft revealed the plans to run and distribute desktop apps (basically all apps ever written for Windows) in the Universal-Windows-Platform “universe”. The project titel was &lt;a href=&quot;https://www.microsoft.com/en-us/download/details.aspx?id=51691&quot;&gt;“Project Centennial”&lt;/a&gt; and a year later the tooling seems to be ok-ish. So, let’s try something simple and convert a simple WPF app to UWP.&lt;/p&gt;

&lt;h2 id=&quot;limitations-with-this-approach&quot;&gt;Limitations with this approach&lt;/h2&gt;

&lt;p&gt;Be aware that even if you can “convert” your WPF app this way you will get a UWP-ish app. The executable will only run &lt;strong&gt;on a normal Windows Desktop System&lt;/strong&gt;. The app will &lt;strong&gt;not work on a Windows Phone, Xbox or HoloLens&lt;/strong&gt; - at least not now.&lt;/p&gt;

&lt;p&gt;Also keep in mind that certain operations might fail and that the outcome of some operations might suprise you. The app itself will run in a kind of sandbox. Calls to the file system or registry will be faked. Details can be found &lt;a href=&quot;https://msdn.microsoft.com/en-us/windows/uwp/porting/desktop-to-uwp-behind-the-scenes&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;As far as I know from a couple of hours playing around:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Changes to the Registry will not leak out of the sandbox, but for the app it will be seen as ok and is persistent&lt;/li&gt;
  &lt;li&gt;Changes to Well-Known-Folders (e.g. %AppData%) will not leak out of the sandbox, but for the app it will be seen as ok and is persistent&lt;/li&gt;
  &lt;li&gt;Some operation can leak out to the actual desktop, e.g. start another programm.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;the-desktop-app-converter&quot;&gt;The Desktop App Converter&lt;/h2&gt;

&lt;p&gt;If you have an existing installer or setup you might want to take a look at the [desktop app converter](https://msdn.microsoft.com/en-us/windows/uwp/porting/desktop-to-uwp-run-desktop-app-converter. This utility will convert the installer to a UWP package.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://mtaulty.com/2016/09/29/a-quick-skip-through-the-desktop-app-converter/&quot;&gt;A quick walk through can be found on Mike Taultys blog&lt;/a&gt;.&lt;/p&gt;

&lt;h2 id=&quot;step-by-step---from-wpf-source-to-uwp-app&quot;&gt;Step by Step - from WPF source to UWP app&lt;/h2&gt;

&lt;p&gt;The important steps from the WPF app to a UWP app are also &lt;a href=&quot;https://msdn.microsoft.com/en-us/windows/uwp/porting/desktop-to-uwp-manual-conversion&quot;&gt;documented in the MSDN&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;But let’s start with a &lt;strong&gt;simple WPF app (running on .NET 4.6.1)&lt;/strong&gt; - this is the MainWindow.xaml&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&amp;lt;Window x:Class=&quot;WpfToUwpTestApp.MainWindow&quot;
        xmlns=&quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;
        xmlns:x=&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot;
        xmlns:d=&quot;http://schemas.microsoft.com/expression/blend/2008&quot;
        xmlns:mc=&quot;http://schemas.openxmlformats.org/markup-compatibility/2006&quot;
        xmlns:local=&quot;clr-namespace:WpfToUwpTestApp&quot;
        mc:Ignorable=&quot;d&quot;
        Title=&quot;MainWindow - WpfToUwpTestApp&quot; Height=&quot;350&quot; Width=&quot;525&quot;&amp;gt;
    &amp;lt;StackPanel&amp;gt;
        &amp;lt;Button Height=&quot;100&quot; Width=&quot;100&quot; Click=&quot;Button_Click1&quot;&amp;gt;Write in Registry&amp;lt;/Button&amp;gt;
        &amp;lt;Button Height=&quot;100&quot; Width=&quot;100&quot; Click=&quot;Button_Click2&quot;&amp;gt;Write in AppData&amp;lt;/Button&amp;gt;
        &amp;lt;Button Height=&quot;100&quot; Width=&quot;100&quot; Click=&quot;Button_Click3&quot;&amp;gt;Open HTTP Address&amp;lt;/Button&amp;gt;

    &amp;lt;/StackPanel&amp;gt;
&amp;lt;/Window&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;The code behind:&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;public partial class MainWindow : Window
{
    public MainWindow()
    {
        InitializeComponent();
    }

    private void Button_Click1(object sender, RoutedEventArgs e)
    {
        RegistryKey key = Registry.CurrentUser.OpenSubKey(&quot;Software&quot;, true);

        key.CreateSubKey(&quot;WpfToUwpTestApp&quot;);
        key = key.OpenSubKey(&quot;WpfToUwpTestApp&quot;, true);


        key.CreateSubKey(&quot;ItWorks&quot;);
        key = key.OpenSubKey(&quot;ItWorks&quot;, true);

        key.SetValue(&quot;ItWorks&quot;, &quot;true&quot;);
    }

    private void Button_Click2(object sender, RoutedEventArgs e)
    {
        string roaming = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);

        string appFolder = System.IO.Path.Combine(roaming, &quot;WpfToUwpTestApp&quot;);

        string file = System.IO.Path.Combine(appFolder, &quot;Test.txt&quot;);

        if (Directory.Exists(appFolder) == false)
        {
            Directory.CreateDirectory(appFolder);
        }

        File.WriteAllText(file, &quot;Hello World!&quot;);
    }

    private void Button_Click3(object sender, RoutedEventArgs e)
    {
        Process.Start(&quot;http://www.google.com&quot;);
    }
}
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Pretty simple, right? Those three operations came just to my mind. In general I wouldn’t use the Registry at all, but I had a use case in mind where I need to access the Registry.&lt;/p&gt;

&lt;p&gt;I also added a couple of dummy store images (from the default UWP app project template) - my solution looks like this:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://blog.codeinside.eu/assets/md-images/2016-09-30/sln.png&quot; alt=&quot;x&quot; title=&quot;Solution&quot; /&gt;&lt;/p&gt;

&lt;p&gt;When we build the .csproj the output should look like this:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;WpfToUwpTestApp.exe&lt;/li&gt;
  &lt;li&gt;appxmanifest.xml&lt;/li&gt;
  &lt;li&gt;Assets/StoreLogo.png&lt;/li&gt;
  &lt;li&gt;Assets/Square150x150Logo.scale-200.png&lt;/li&gt;
  &lt;li&gt;Assets/Square44x44Logo.scale-200.png&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;the-appmanifestxml&quot;&gt;The appmanifest.xml&lt;/h2&gt;

&lt;p&gt;The next step is to create the &lt;strong&gt;appmanifest.xml&lt;/strong&gt; - on the &lt;a href=&quot;https://msdn.microsoft.com/en-us/windows/uwp/porting/desktop-to-uwp-manual-conversion&quot;&gt;MSDN there is a handy template&lt;/a&gt;. The Desktop App Converter does the same thing and tries to create this file automatically, but it’s not that hard to set it by hand:&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;cp&quot;&gt;&amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;Package&lt;/span&gt;
   &lt;span class=&quot;na&quot;&gt;xmlns=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;http://schemas.microsoft.com/appx/manifest/foundation/windows10&quot;&lt;/span&gt;
   &lt;span class=&quot;na&quot;&gt;xmlns:uap=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;http://schemas.microsoft.com/appx/manifest/uap/windows10&quot;&lt;/span&gt;
   &lt;span class=&quot;na&quot;&gt;xmlns:rescap=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;Identity&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;Name=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;WpfToUwpTestApp&quot;&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;ProcessorArchitecture=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;x64&quot;&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Publisher=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;CN=Robert&quot;&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;Version=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;1.0.0.0&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;Properties&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;DisplayName&amp;gt;&lt;/span&gt;WpfToUwpTestApp&lt;span class=&quot;nt&quot;&gt;&amp;lt;/DisplayName&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;PublisherDisplayName&amp;gt;&lt;/span&gt;Robert&lt;span class=&quot;nt&quot;&gt;&amp;lt;/PublisherDisplayName&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;Description&amp;gt;&lt;/span&gt;No description entered&lt;span class=&quot;nt&quot;&gt;&amp;lt;/Description&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;Logo&amp;gt;&lt;/span&gt;Assets/StoreLogo.png&lt;span class=&quot;nt&quot;&gt;&amp;lt;/Logo&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;/Properties&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;Resources&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;Resource&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;Language=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;en-us&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;/Resources&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;Dependencies&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;TargetDeviceFamily&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;Name=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Windows.Desktop&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;MinVersion=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;10.0.14316.0&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;MaxVersionTested=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;10.0.14316.0&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;/Dependencies&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;Capabilities&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;rescap:Capability&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;Name=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;runFullTrust&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;/Capabilities&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;Applications&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;Application&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;Id=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Test&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;Executable=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;WpfToUwpTestApp.exe&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;EntryPoint=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Windows.FullTrustApplication&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;
      &lt;span class=&quot;nt&quot;&gt;&amp;lt;uap:VisualElements&lt;/span&gt;
       &lt;span class=&quot;na&quot;&gt;BackgroundColor=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;#464646&quot;&lt;/span&gt;
       &lt;span class=&quot;na&quot;&gt;DisplayName=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;WpfToUwpTestApp&quot;&lt;/span&gt;
       &lt;span class=&quot;na&quot;&gt;Square150x150Logo=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Assets/Square150x150Logo.scale-200.png&quot;&lt;/span&gt;
       &lt;span class=&quot;na&quot;&gt;Square44x44Logo=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Assets/Square44x44Logo.scale-200.png&quot;&lt;/span&gt;
       &lt;span class=&quot;na&quot;&gt;Description=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;WpfUwpWriteInRegistry - Desc&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;/Application&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;/Applications&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;/Package&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;h2 id=&quot;create-the-appappx-package&quot;&gt;Create the App.appx package&lt;/h2&gt;

&lt;p&gt;Now we are ready to create the appx package. You need the Windows 10 SDK to do this.&lt;/p&gt;

&lt;p&gt;To simplify things, I copied the needed files from the build output to a folder called _App.&lt;/p&gt;

&lt;p&gt;To create the package, invoke the following command:&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&quot;C:\Program Files (x86)\Windows Kits\10\bin\x64\makeappx.exe&quot; pack -d &quot;%~dp0_App&quot; -p &quot;%~dp0App.appx&quot;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;The result is a unsigned appx package called “App”.&lt;/p&gt;

&lt;h2 id=&quot;create-a-valid-pfx-one-time-only&quot;&gt;Create a valid pfx (one time only)&lt;/h2&gt;

&lt;p&gt;In the following step we need a valid pfx to sign the package. For development you can use this command to create a pfx:&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&quot;C:\Program Files (x86)\Windows Kits\10\bin\x64\makecert.exe&quot; -r -h 0 -n &quot;CN=Robert&quot; -eku 1.3.6.1.5.5.7.3.3 -pe -sv App.pvk App.cer 

&quot;C:\Program Files (x86)\Windows Kits\10\bin\x64\pvk2pfx.exe&quot; -pvk App.pvk -spc App.cer -pfx App.pfx -po apptest
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;After this you should see a “App.pfx” in the folder. I’m not 100% sure if this step is really needed, but I needed to do it, otherwise I couldn’t install the app:&lt;/p&gt;

&lt;p&gt;Now click on the pfx and enter the password “apptest” and import it in the “Trusted Root CAs”:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://blog.codeinside.eu/assets/md-images/2016-09-30/trust.png&quot; alt=&quot;x&quot; title=&quot;Importing the pfx&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;sign-appappx&quot;&gt;Sign App.appx&lt;/h2&gt;

&lt;p&gt;Now we need to sign the package and we are done:&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&quot;C:\Program Files (x86)\Windows Kits\10\bin\x64\signtool.exe&quot; sign /f &quot;App.pfx&quot; -fd SHA256 /p apptest &quot;App.appx&quot;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;h2 id=&quot;install-the-app&quot;&gt;Install the App!&lt;/h2&gt;

&lt;p&gt;Now you can double click on the appx package and the installer will show up:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://blog.codeinside.eu/assets/md-images/2016-09-30/install.png&quot; alt=&quot;x&quot; title=&quot;install the app&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;running-the-app&quot;&gt;Running the App&lt;/h2&gt;

&lt;p&gt;And there is our beauty:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://blog.codeinside.eu/assets/md-images/2016-09-30/app.png&quot; alt=&quot;x&quot; title=&quot;running the app&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;exploring-the-sandbox&quot;&gt;Exploring the sandbox:&lt;/h2&gt;

&lt;p&gt;Remember our 3 methods? The results of those three calls are:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Write to the Registry: Seems to work for the app, but (as expected) the registry value will not leak out of the “sandbox”&lt;/li&gt;
  &lt;li&gt;Write to %appdata%: Seems to work for the app, but the data value will not leak out of the “sandbox”&lt;/li&gt;
  &lt;li&gt;Open a browser: The default browser will be invoked for a HTTP url.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It was my first try to convert a (simple) WPF app to UWP and the result is interesting.&lt;/p&gt;

&lt;p&gt;Hope my first steps in this world might help you!&lt;/p&gt;

&lt;p&gt;The code and a handy readme.txt is available on &lt;a href=&quot;https://github.com/Code-Inside/Samples/tree/master/2016/WpfToUwpTestApp&quot;&gt;GitHub&lt;/a&gt;.&lt;/p&gt;
</description>
                <link>https://blog.codeinside.eu/2016/09/30/lets-convert-a-wpf-app-to-uwp-via-the-uwp-bridge/</link>
                <guid>https://blog.codeinside.eu/2016/09/30/lets-convert-a-wpf-app-to-uwp-via-the-uwp-bridge</guid>
                <pubDate>Fri, 30 Sep 2016 23:45:00 +0000</pubDate>
        </item>

        <item>
                <title>TFS 2015: Adding a new Windows Build Agent</title>
                <description>
&lt;h2 id=&quot;the-tfs-2015-build-system&quot;&gt;The TFS 2015 Build System&lt;/h2&gt;

&lt;p&gt;The build system before TFS 2015 was based on a pretty arcane XAML workflow engine which was manageable, but not fun to use. With TFS 2015 a new build system was implemented, which behave pretty much the same way as other build systems (e.g. TeamCity or AppVeyor).&lt;/p&gt;

&lt;p&gt;The “build workflow” is based on a simple “task”-concept.&lt;/p&gt;

&lt;p&gt;There are many related topics in the TFS world, e.g. Release-Management, but this blogpost will just focus on the “Getting the system ready”-part.&lt;/p&gt;

&lt;h2 id=&quot;tfs-build-agents&quot;&gt;TFS Build Agents&lt;/h2&gt;

&lt;p&gt;Like the other parts of Microsoft the TFS is now also in the cross-platform business. The build system in TFS 2015 is capable of building a huge range of languages. All you need is a 
compatible build agent.&lt;/p&gt;

&lt;p&gt;My (simple) goal was to build a .NET application on a Windows build agent via the new TFS 2015 build system.&lt;/p&gt;

&lt;h2 id=&quot;step-1-adding-a-new-build-agent&quot;&gt;Step 1: Adding a new build agent&lt;/h2&gt;

&lt;p&gt;&lt;img src=&quot;https://blog.codeinside.eu/assets/md-images/2016-08-10/adding-buildagent.png&quot; alt=&quot;Important - Download Agent&quot; title=&quot;Important - Download Agent&quot; /&gt;.&lt;/p&gt;

&lt;p&gt;This one is maybe the hardest part. Instead of a huge TFS-Agent-Installer.msi you need to navigate inside the TFS control panel to the &lt;strong&gt;“Agent pool”&lt;/strong&gt;-tab.&lt;/p&gt;

&lt;p&gt;You need at least one pool and need to click the “Download Agent” button.&lt;/p&gt;

&lt;h2 id=&quot;step-2-configure-the-agent&quot;&gt;Step 2: Configure the agent&lt;/h2&gt;

&lt;p&gt;&lt;img src=&quot;https://blog.codeinside.eu/assets/md-images/2016-08-10/config-buildagent.png&quot; alt=&quot;Configuration&quot; title=&quot;Configuration&quot; /&gt;.&lt;/p&gt;

&lt;p&gt;The .zip package contains the actual build agent executable and a .cmd file.&lt;/p&gt;

&lt;p&gt;Invoke the &lt;strong&gt;“ConfigureAgent.cmd”&lt;/strong&gt;-file:&lt;/p&gt;

&lt;p&gt;We run those agents as Windows Service (which was one of the last config-questions) and are pretty happy with the system.&lt;/p&gt;

&lt;h2 id=&quot;step-3-you-are-done&quot;&gt;Step 3: You are done&lt;/h2&gt;

&lt;p&gt;Now your new build agent should appear under the given build agent pool:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://blog.codeinside.eu/assets/md-images/2016-08-10/resulting-buildagent.png&quot; alt=&quot;TFS Build Agents&quot; title=&quot;TFS Build Agents&quot; /&gt;.&lt;/p&gt;

&lt;h2 id=&quot;msdn-link&quot;&gt;MSDN Link&lt;/h2&gt;

&lt;p&gt;After googleing around I also found the &lt;strong&gt;&lt;a href=&quot;https://www.visualstudio.com/en-us/docs/build/agents/windows&quot;&gt;corresponding TFS HowTo&lt;/a&gt;&lt;/strong&gt;, which describes more or less the complete setup. Well… now it is documented on MSDN and this blog. Maybe this will help my future-self ;)&lt;/p&gt;
</description>
                <link>https://blog.codeinside.eu/2016/08/10/adding-a-new-windowsagent-to-tfs2015-build/</link>
                <guid>https://blog.codeinside.eu/2016/08/10/adding-a-new-windowsagent-to-tfs2015-build</guid>
                <pubDate>Wed, 10 Aug 2016 23:45:00 +0000</pubDate>
        </item>

        <item>
                <title>CAKE: Building solutions with C# &amp; Roslyn</title>
                <description>
&lt;p&gt;&lt;img src=&quot;https://blog.codeinside.eu/assets/md-images/2016-07-09/cake.png&quot; alt=&quot;x&quot; title=&quot;CAKE - C# Make&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;cake---c-make&quot;&gt;CAKE - C# Make&lt;/h2&gt;

&lt;ul&gt;
  &lt;li&gt;A DSL for build tasks (e.g. build following projects, copy stuff, deploy stuff etc.)&lt;/li&gt;
  &lt;li&gt;It’s just C# code that gets compiled via Roslyn&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/cake-build/cake&quot;&gt;Active community, OSS &amp;amp; written in C#&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;You can get CAKE via &lt;a href=&quot;https://www.nuget.org/packages/Cake&quot;&gt;NuGet&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;Before we begin you might want to check out the actual website of &lt;a href=&quot;http://cakebuild.net/&quot;&gt;CAKE&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;Cross Platform support&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Our goal: Building, running tests, package NuGet Packages etc.&lt;/p&gt;

&lt;h2 id=&quot;related-msbuild-and-fake-blogposts&quot;&gt;Related: MSBuild and FAKE blogposts&lt;/h2&gt;

&lt;p&gt;I already did a couple of MSBuild and FAKE related blogposts, so if you are interested on these topics as well go ahead (some are quite old, there is a high chance that some pieces might not apply anymore):&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;http://blog.codeinside.eu/2010/12/15/howto-msbuild-stylecop/&quot;&gt;MSBuild &amp;amp; Stylecop&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://blog.codeinside.eu/2010/11/12/howto-build-msbuild-solutions/&quot;&gt;MSBuild &amp;amp; Building solutions&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://blog.codeinside.eu/2010/11/21/howto-msdeploy-msbuild/&quot;&gt;MSBuild &amp;amp; MSDeploy&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://blog.codeinside.eu/2010/11/24/howto-open-mstest-with-msbuild-2/&quot;&gt;MSBuild &amp;amp; MSTest 1&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://blog.codeinside.eu/2010/11/29/howto-open-mstest-with-msbuild/&quot;&gt;MSBuild &amp;amp; MSTest 2&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://blog.codeinside.eu/2011/01/06/howto-msbuild-nuit/&quot;&gt;MSBuild &amp;amp; NUnit&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;a href=&quot;http://blog.codeinside.eu/2010/12/06/howto-web-config-transformations-with-msbuild/&quot;&gt;MSBuild &amp;amp; Web.config Transformations&lt;/a&gt;&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://blog.codeinside.eu/2015/02/23/fake-building-with-fake/&quot;&gt;“FAKE: Building C# projects without knowing a tiny bit of F#”&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://blog.codeinside.eu/2015/02/24/fake-running-xunit-tests-with-fake/&quot;&gt;“FAKE: Running xUnit Tests with FAKE without knowing a tiny bit of F#”&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://blog.codeinside.eu/2015/06/21/fake-create-nuget-packages/&quot;&gt;“FAKE: Create NuGet Packages without knowing a tiny bit of F#”&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://blog.codeinside.eu/2015/08/30/fake-running-mstest-tests-with-fake/&quot;&gt;“FAKE: Running MSTest Tests with FAKE without knowing a tiny bit of F#”&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://blog.codeinside.eu/2016/06/12/fake-build-aspnet-projects-with-webconfig-transform/&quot;&gt;“FAKE: Build ASP.NET projects with web.config transformation (and without knowing a tiny bit of F#)”&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Ok… now back to CAKE.&lt;/p&gt;

&lt;h2 id=&quot;lets-start-with-the-basics-building&quot;&gt;Let’s start with the basics: Building&lt;/h2&gt;

&lt;p&gt;I created a pretty simple WPF app and &lt;a href=&quot;http://cakebuild.net/docs/tutorials/setting-up-a-new-project&quot;&gt;followed these instructions&lt;/a&gt;.&lt;/p&gt;

&lt;h2 id=&quot;the-buildcake-script&quot;&gt;The build.cake script&lt;/h2&gt;

&lt;p&gt;My script is a simplified version &lt;a href=&quot;https://github.com/cake-build/example/blob/master/build.cake&quot;&gt;of this build script&lt;/a&gt;:&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;// ARGUMENTS
var target = Argument(&quot;target&quot;, &quot;Default&quot;);

// TASKS
Task(&quot;Restore-NuGet-Packages&quot;)
    .Does(() =&amp;gt;
{
    NuGetRestore(&quot;CakeExampleWithWpf.sln&quot;);
});

Task(&quot;Build&quot;)
    .IsDependentOn(&quot;Restore-NuGet-Packages&quot;)
    .Does(() =&amp;gt;
{
      MSBuild(&quot;CakeExampleWithWpf.sln&quot;, settings =&amp;gt;
        settings.SetConfiguration(&quot;Release&quot;));

});

// TASK TARGETS
Task(&quot;Default&quot;).IsDependentOn(&quot;Build&quot;);

// EXECUTION
RunTarget(target);
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;If you know FAKE or MSBuild, this is more or less the same structure. You define tasks, which may depend on other tasks. At the end you invoke one task and the dependency chain will do its work.&lt;/p&gt;

&lt;h2 id=&quot;invoke-buildcake&quot;&gt;Invoke build.cake&lt;/h2&gt;

&lt;p&gt;The “build.ps1” will invoke “tools/cake.exe” with the input file “build.cake”.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;“build.ps1” is just a helper.&lt;/strong&gt; 
This Powershell script will download nuget.exe and download the CAKE NuGet-Package and extract it under a /tools folder. If you don’t have problems with binary files in your source control, you don’t need this Powershell script.&lt;/p&gt;

&lt;h2 id=&quot;our-first-cake-script&quot;&gt;Our first CAKE script!&lt;/h2&gt;

&lt;p&gt;The output is very well formatted and should explain the mechanics behind it good enough:&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;Time Elapsed 00:00:02.86
Finished executing task: Build

========================================
Default
========================================
Executing task: Default
Finished executing task: Default

Task                          Duration
--------------------------------------------------
Restore-NuGet-Packages        00:00:00.5192250
Build                         00:00:03.1315658
Default                       00:00:00.0113019
--------------------------------------------------
Total:                        00:00:03.6620927
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;The first steps are pretty easy and it’s much easier than MSBuild and feels good if you know C#.&lt;/p&gt;

&lt;p&gt;The super simple intro code can be found on &lt;a href=&quot;https://github.com/Code-Inside/Samples/tree/master/2016/CakeIntro&quot;&gt;&lt;strong&gt;GitHub&lt;/strong&gt;&lt;/a&gt;.&lt;/p&gt;
</description>
                <link>https://blog.codeinside.eu/2016/07/09/cake-building-with-cake/</link>
                <guid>https://blog.codeinside.eu/2016/07/09/cake-building-with-cake</guid>
                <pubDate>Sat, 09 Jul 2016 14:15:00 +0000</pubDate>
        </item>

        <item>
                <title>FAKE: Build ASP.NET projects with web.config transformation (and without knowing a tiny bit of F#)</title>
                <description>
&lt;p&gt;&lt;em&gt;This is a follow-up to my other FAKE posts:&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;http://blog.codeinside.eu/2015/02/23/fake-building-with-fake/&quot;&gt;“FAKE: Building C# projects without knowing a tiny bit of F#”&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://blog.codeinside.eu/2015/02/24/fake-running-xunit-tests-with-fake/&quot;&gt;“FAKE: Running xUnit Tests with FAKE without knowing a tiny bit of F#”&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://blog.codeinside.eu/2015/06/21/fake-create-nuget-packages/&quot;&gt;“FAKE: Create NuGet Packages without knowing a tiny bit of F#”&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://blog.codeinside.eu/2015/08/30/fake-running-mstest-tests-with-fake/&quot;&gt;“FAKE: Running MSTest Tests with FAKE without knowing a tiny bit of F#”&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;whats-the-difference-between-a-aspnet-and-other-projects&quot;&gt;What’s the difference between a ASP.NET and other projects?&lt;/h2&gt;

&lt;p&gt;The most obvious difference is that the output is a bunch of dlls and content files. Additionally you might have a &lt;strong&gt;web.debug.config or web.release.config&lt;/strong&gt; in your source folder.&lt;/p&gt;

&lt;p&gt;Both files are important, because they are used during a Visual-Studio build as a &lt;a href=&quot;https://msdn.microsoft.com/en-us/library/dd465326(v=vs.110).aspx&quot;&gt;&lt;strong&gt;Web.Config Transformation&lt;/strong&gt;&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;With a normal build the transformation will not kick in, so we need a way to trigger the transformation “manually”.&lt;/p&gt;

&lt;h2 id=&quot;project-overview&quot;&gt;Project Overview&lt;/h2&gt;

&lt;p&gt;The sample project consists of one ASP.NET project and the .fsx file.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://blog.codeinside.eu/assets/md-images/2016-06-12/project.png&quot; alt=&quot;x&quot; title=&quot;Project Overview&quot; /&gt;&lt;/p&gt;

&lt;p&gt;The “released” web.config should cover this 3 main transformation parts:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;DefaultConnectionString to ‘ReleaseSQLServer’&lt;/li&gt;
  &lt;li&gt;No “debug”-attribute on system.web&lt;/li&gt;
  &lt;li&gt;developmentMode-AppSetting set to ‘true’&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Web.Release.config&lt;/strong&gt;&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;cp&quot;&gt;&amp;lt;?xml version=&quot;1.0&quot;?&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;configuration&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;xmlns:xdt=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;http://schemas.microsoft.com/XML-Document-Transform&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;connectionStrings&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;add&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;name=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;DefaultConnection&quot;&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;connectionString=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;ReleaseSQLServer&quot;&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;xdt:Transform=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;SetAttributes&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;xdt:Locator=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Match(name)&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;/connectionStrings&amp;gt;&lt;/span&gt;

  &lt;span class=&quot;nt&quot;&gt;&amp;lt;appSettings&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;add&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;key=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;developmentMode&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;value=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;true&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;xdt:Transform=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;SetAttributes&quot;&lt;/span&gt;
         &lt;span class=&quot;na&quot;&gt;xdt:Locator=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Match(key)&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;/appSettings&amp;gt;&lt;/span&gt;
  
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;system.web&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;compilation&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;xdt:Transform=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;RemoveAttributes(debug)&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;/system.web&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;/configuration&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;h2 id=&quot;the-fake-script&quot;&gt;The FAKE script&lt;/h2&gt;

&lt;p&gt;We reuse the MSBuild-Helper from FAKE and inject a couple of “Publish”-related stuff, which will trigger the transformation.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;A few remarks:&lt;/strong&gt; In the “normal” WebDeploy-World you would have a PublishProfile and it would end up with a .zip-file and a couple of other files that fill in parameters like the ConnectionString. With this MSBuild command I mimik a part of this behavior and use the temporary output as our main artifact. In my most apps I use web.config transformations only for “easy” stuff (e.g. remove the debug attribute) - if you are doing fancy stuff and the output is not what you want, please let me know.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;This MSBuild command &lt;em&gt;should&lt;/em&gt; apply all your web.config transformations.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Publish a ASP.NET project&lt;/strong&gt;&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;...
Target &quot;BuildWebApp&quot; (fun _ -&amp;gt;
trace &quot;Building WebHosted Connect...&quot;
!! &quot;**/*.csproj&quot;
 |&amp;gt; MSBuild artifactsBuildDir &quot;Package&quot;
    [&quot;Configuration&quot;, &quot;Release&quot;
     &quot;Platform&quot;, &quot;AnyCPU&quot;
     &quot;AutoParameterizationWebConfigConnectionStrings&quot;, &quot;False&quot;
     &quot;_PackageTempDir&quot;, (@&quot;..\&quot; + artifactsDir + @&quot;Release-Ready-WebApp&quot;)
     ]
 |&amp;gt; Log &quot;AppBuild-Output: &quot;
)
...
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;h3 id=&quot;autoparameterizationwebconfigconnectionstrings-or-how-to-get-rid-of-replacabletoken&quot;&gt;“AutoParameterizationWebConfigConnectionStrings” or how to get rid of $(ReplacableToken_…&lt;/h3&gt;

&lt;p&gt;&lt;em&gt;Blogpost updated on 2016-07-18&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;A friend told me that his transformed web.config contained “$(ReplaceableToken_…)” strings. It seems that “connectionStrings” are treated specially. If you have a connectionString in your web.config and don’t set &lt;a href=&quot;http://stackoverflow.com/questions/7207689/how-to-get-rid-of-replacabletoken-in-web-config-completely&quot;&gt;“AutoParameterizationWebConfigConnectionStrings=False”&lt;/a&gt; you will get something like that:&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&amp;lt;connectionStrings&amp;gt;
  &amp;lt;!-- Not the result we are looking for :-/ --&amp;gt;
  &amp;lt;add name=&quot;DefaultConnection&quot; connectionString=&quot;$(ReplacableToken_DefaultConnection-Web.config Connection String_0)&quot; providerName=&quot;System.Data.SqlClient&quot; /&amp;gt;
&amp;lt;/connectionStrings&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;I would say this is not the result you are expecting. With the “AutoParameterizationWebConfigConnectionStrings=False” parameter it should either do a transformation or leave the default-connectionString value in the result.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Thanks to Timur Zanagar! I completely missed this issue.&lt;/em&gt;&lt;/p&gt;

&lt;h2 id=&quot;result&quot;&gt;Result&lt;/h2&gt;

&lt;p&gt;&lt;img src=&quot;https://blog.codeinside.eu/assets/md-images/2016-06-12/output.png&quot; alt=&quot;x&quot; title=&quot;Output&quot; /&gt;&lt;/p&gt;

&lt;p&gt;This build will produce two artifacts - the build-folder just contains the normal build output, but &lt;strong&gt;without&lt;/strong&gt; a web.config transformation.&lt;/p&gt;

&lt;p&gt;The other folder contains a ready to deploy web application, &lt;strong&gt;with the web.release.config applied&lt;/strong&gt;.&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&amp;lt;connectionStrings&amp;gt;
  &amp;lt;add name=&quot;DefaultConnection&quot; connectionString=&quot;ReleaseSQLServer&quot; providerName=&quot;System.Data.SqlClient&quot; /&amp;gt;
&amp;lt;/connectionStrings&amp;gt;
&amp;lt;appSettings&amp;gt;
  ...
  &amp;lt;add key=&quot;developmentMode&quot; value=&quot;true&quot; /&amp;gt;
&amp;lt;/appSettings&amp;gt;
&amp;lt;system.web&amp;gt;
  ...
&amp;lt;/system.web&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;You can find the complete &lt;a href=&quot;https://github.com/Code-Inside/Samples/tree/master/2016/LetsUseFake-AspNet&quot;&gt;sample &amp;amp; build script on GitHub&lt;/a&gt;.&lt;/p&gt;
</description>
                <link>https://blog.codeinside.eu/2016/06/12/fake-build-aspnet-projects-with-webconfig-transform/</link>
                <guid>https://blog.codeinside.eu/2016/06/12/fake-build-aspnet-projects-with-webconfig-transform</guid>
                <pubDate>Sun, 12 Jun 2016 14:00:00 +0000</pubDate>
        </item>

        <item>
                <title>Copy to clipboard with Javascript</title>
                <description>
&lt;h2 id=&quot;clipboard-current-state-of-the-art&quot;&gt;Clipboard? Current state of the art…&lt;/h2&gt;

&lt;p&gt;I think everybody knows the clipboard. The goal is that we can store text inside the users clipboard, so he can just paste it. Most sites uses either Flash or some sort of mini-popup with a pre-selected text inside a textarea.&lt;/p&gt;

&lt;p&gt;Both ways are not super user friendly and Flash is definitely done.&lt;/p&gt;

&lt;h2 id=&quot;clipboard-api&quot;&gt;Clipboard API?&lt;/h2&gt;

&lt;p&gt;Currently there are some draft specs for a real clipboard API, but as far as I know, it’s far from &lt;a href=&quot;http://caniuse.com/#feat=clipboard&quot;&gt;done&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The good news:&lt;/strong&gt; For our use case there is a pretty handy workaround available, which I found on &lt;a href=&quot;http://stackoverflow.com/questions/400212/how-do-i-copy-to-the-clipboard-in-javascript&quot;&gt;StackOverflow&lt;/a&gt;.&lt;/p&gt;

&lt;h2 id=&quot;the-code&quot;&gt;The code:&lt;/h2&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&amp;lt;script&amp;gt;
    function detectIE() {
        var ua = window.navigator.userAgent;

        var msie = ua.indexOf('MSIE ');
        if (msie &amp;gt; 0) {
            // IE 10 or older =&amp;gt; return version number
            return parseInt(ua.substring(msie + 5, ua.indexOf('.', msie)), 10);
        }

        var trident = ua.indexOf('Trident/');
        if (trident &amp;gt; 0) {
            // IE 11 =&amp;gt; return version number
            var rv = ua.indexOf('rv:');
            return parseInt(ua.substring(rv + 3, ua.indexOf('.', rv)), 10);
        }

        // other browser or edge
        return false;
    }

    // source: http://stackoverflow.com/questions/400212/how-do-i-copy-to-the-clipboard-in-javascript
    // enhancement with special case for IEs, otherwise the temp textarea will be visible
    function copyTextToClipboard(text) {
        if (detectIE()) {
            try {
                window.clipboardData.setData('Text', text);
                console.log('Copying text command via IE-setData');
            } catch (err) {
                console.log('Oops, unable to copy via IE-setData');
            }
        }
        else {

            var textArea = document.createElement(&quot;textarea&quot;);

            //
            //  This styling is an extra step which is likely not required. 
            //
            // Why is it here? To ensure:
            // 1. the element is able to have focus and selection.
            // 2. if element was to flash render it has minimal visual impact.
            // 3. less flakyness with selection and copying which might occur if
            //    the textarea element is not visible.
            //
            // The likelihood is the element won't even render, not even a flash,
            // so some of these are just precautions. 
            // 
            // However in IE the element
            // is visible whilst the popup box asking the user for permission for
            // the web page to copy to the clipboard. To prevent this, we are using 
            // the detectIE workaround.

            // Place in top-left corner of screen regardless of scroll position.
            textArea.style.position = 'fixed';
            textArea.style.top = 0;
            textArea.style.left = 0;

            // Ensure it has a small width and height. Setting to 1px / 1em
            // doesn't work as this gives a negative w/h on some browsers.
            textArea.style.width = '2em';
            textArea.style.height = '2em';

            // We don't need padding, reducing the size if it does flash render.
            textArea.style.padding = 0;

            // Clean up any borders.
            textArea.style.border = 'none';
            textArea.style.outline = 'none';
            textArea.style.boxShadow = 'none';

            // Avoid flash of white box if rendered for any reason.
            textArea.style.background = 'transparent';


            textArea.value = text;

            document.body.appendChild(textArea);

            textArea.select();

            try {
                var successful = document.execCommand('copy');
                var msg = successful ? 'successful' : 'unsuccessful';
                console.log('Copying text command was ' + msg);
            } catch (err) {
                console.log('Oops, unable to copy');
            }

            document.body.removeChild(textArea);
        }

    }
&amp;lt;/script&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;h2 id=&quot;usage&quot;&gt;Usage:&lt;/h2&gt;

&lt;p&gt;The usage is pretty simple, just call copyToClipboard, e.g.&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&amp;lt;button type=&quot;button&quot; onclick=&quot;copyTextToClipboard('Foobar!')&quot;&amp;gt;
	Set Foobar to clipboard
&amp;lt;/button&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;h2 id=&quot;documentexeccommandcopy&quot;&gt;document.execCommand(‘copy’)&lt;/h2&gt;

&lt;p&gt;This API is a bit strange, because it only works for visible elements and IE might render a small warning. To get rid of this effect we use a older IE-only API. “document.execCommand” is not limited to copy - there are some nice ideas around it. The &lt;strong&gt;&lt;a href=&quot;https://developer.mozilla.org/de/docs/Web/API/Document/execCommand&quot;&gt;Mozilla site&lt;/a&gt;&lt;/strong&gt; has a large documentation about this function.&lt;/p&gt;

&lt;p&gt;A full demo is available on &lt;strong&gt;&lt;a href=&quot;https://jsfiddle.net/uxozxb04/1/&quot;&gt;JSFiddle&lt;/a&gt;&lt;/strong&gt; and the code is stored on &lt;a href=&quot;https://github.com/Code-Inside/Samples/tree/master/2016/clipboardjs&quot;&gt;&lt;strong&gt;GitHub&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Hope this helps.&lt;/p&gt;
</description>
                <link>https://blog.codeinside.eu/2016/05/12/copy-to-clipboard-with-javascript/</link>
                <guid>https://blog.codeinside.eu/2016/05/12/copy-to-clipboard-with-javascript</guid>
                <pubDate>Thu, 12 May 2016 23:55:00 +0000</pubDate>
        </item>

        <item>
                <title>Get the Windows 10 or 8 accent color in WPF</title>
                <description>
&lt;p&gt;&lt;img src=&quot;https://blog.codeinside.eu/assets/md-images/2016-04-26/windows-accent.png&quot; alt=&quot;x&quot; title=&quot;Windows Color Options&quot; /&gt;.&lt;/p&gt;

&lt;h2 id=&quot;windows-accent-color&quot;&gt;Windows Accent Color&lt;/h2&gt;

&lt;p&gt;Since Windows 8 users can choose a system accent color. The color can be seen on the window borders of the default apps and it can be pretty easy be used inside a &lt;a href=&quot;http://firstfloorsoftware.com/news/win10-dev-using-systemaccentcolor&quot;&gt;UWP App&lt;/a&gt;.&lt;/p&gt;

&lt;h2 id=&quot;how-to-get-the-accent-color-in-wpf&quot;&gt;How to get the accent color in WPF?&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Option 1: SystemParameters.WindowGlassBrush - not 100% the same color&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;As far as I know there are several ways to get the color code, one easy but &lt;strong&gt;not 100% correct&lt;/strong&gt; way is to use the &lt;a href=&quot;https://msdn.microsoft.com/en-us/library/system.windows.systemparameters.windowglassbrush.aspx&quot;&gt;SystemParameters.WindowGlassBrush&lt;/a&gt; property that was introduced in .NET 4.5.&lt;/p&gt;

&lt;p&gt;Sadly, the color is not 100% correct - I have no idea where this “similar”, but not identical color is used and why the API is returning this color.&lt;/p&gt;

&lt;p&gt;It seems this is just a wrapper around the &lt;strong&gt;undocumented&lt;/strong&gt; DwmGetColorizationParameters Win32 API.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Option 2: GetImmersiveColorFromColorSetEx&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;I found this solution &lt;a href=&quot;https://gist.github.com/paulcbetts/3c6aedc9f0cd39a77c37&quot;&gt;here&lt;/a&gt;, which is just a wrapper around the &lt;strong&gt;GetImmersiveColorFromColorSetEx&lt;/strong&gt; Win32 API.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Option 3: Registry, DwmGetColorizationParameters&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The last option would be to read the Registry values - I found some hints on this &lt;a href=&quot;http://pinvoke.net/default.aspx/dwmapi/DwmGetColorizationParameters.html&quot;&gt;site&lt;/a&gt;, but I wouldn’t recommend it, because it is more or less undocumented and might break in the future. So we will use option 1 or 2.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Usage:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The usage of both options is pretty easy (at least with the option 2 code provided) :&lt;/p&gt;

&lt;div class=&quot;language-cs highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;    &lt;span class=&quot;c1&quot;&gt;// https://gist.github.com/paulcbetts/3c6aedc9f0cd39a77c37
&lt;/span&gt;    &lt;span class=&quot;kt&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;accentColor&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;SolidColorBrush&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;AccentColorSet&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ActiveSet&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;SystemAccent&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]);&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Code&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Background&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;accentColor&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Code&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Text&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;AccentColorSet Immersive 'SystemAccent' &quot;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;accentColor&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Color&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;ToString&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;

    &lt;span class=&quot;c1&quot;&gt;// Available in .NET 4.5
&lt;/span&gt;    &lt;span class=&quot;k&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;SystemProperties&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Background&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;SystemParameters&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;WindowGlassBrush&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;SystemProperties&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Text&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;SystemParameters.WindowGlassBrush &quot;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;((&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;SolidColorBrush&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;SystemParameters&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;WindowGlassBrush&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Color&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;ToString&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Result:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://blog.codeinside.eu/assets/md-images/2016-04-26/wpf-result.png&quot; alt=&quot;x&quot; title=&quot;WPF result&quot; /&gt;.&lt;/p&gt;

&lt;p&gt;&lt;del&gt;As you can see, the lower color does match the border color instead of the first option. Crazy, right?&lt;/del&gt; ¯\_(ツ)_/¯&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;From the comments:&lt;/strong&gt; As Yves Goergen pointed out, the resulting color &lt;strong&gt;does not&lt;/strong&gt; exactly match the &lt;strong&gt;border color&lt;/strong&gt;, but it &lt;strong&gt;does match the system accent color&lt;/strong&gt;, which is ok. I would guess that the border has some chrome behavior attached so that the color is slightly different.&lt;/p&gt;

&lt;p&gt;The full code is on &lt;a href=&quot;https://github.com/Code-Inside/Samples/tree/master/2016/WpfGetWindows10AccentColor&quot;&gt;&lt;strong&gt;GitHub&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Hope this helps.&lt;/p&gt;

</description>
                <link>https://blog.codeinside.eu/2016/04/26/get-the-windows-10-or-8-accent-color-from-wpf/</link>
                <guid>https://blog.codeinside.eu/2016/04/26/get-the-windows-10-or-8-accent-color-from-wpf</guid>
                <pubDate>Tue, 26 Apr 2016 23:55:00 +0000</pubDate>
        </item>

        <item>
                <title>Debugging .NET based Windows Error Reports (WER)</title>
                <description>
&lt;p&gt;&lt;img src=&quot;https://blog.codeinside.eu/assets/md-images/2016-03-23/crash.gif&quot; alt=&quot;x&quot; title=&quot;Windows App Crash&quot; /&gt;.&lt;/p&gt;

&lt;h2 id=&quot;the-last-hope-windows-error-reports&quot;&gt;The last hope: Windows Error Reports&lt;/h2&gt;

&lt;p&gt;The “Windows Error Report” (WER) is automatically generated by Windows and can be seen in the Eventlog. In most cases, you might see some other - debugging friendlier - event logs. If there is a event log from with the source “.NET Runtime”, then use this first. Windows Error Reports are at first a bit strange to read.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://blog.codeinside.eu/assets/md-images/2016-03-23/eventlog-wer.png&quot; alt=&quot;x&quot; title=&quot;Windows Error Report&quot; /&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Small, but important hint:&lt;/strong&gt;
I strongly recommend that you should use some logging libraries inside your application as well.&lt;/p&gt;

&lt;p&gt;If you still don’t have a clue where your application breaks or those other event logs are missing the WER can be used to see where the exception is thrown in your .NET application.&lt;/p&gt;

&lt;h2 id=&quot;windows-error-report-for-net-apps&quot;&gt;Windows Error Report for .NET Apps&lt;/h2&gt;

&lt;p&gt;A typical Windows Error Report could look like this:&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;Fault bucket 129047406839, type 5
Event Name: CLR20r3
Response: Not available
Cab Id: 0

Problem signature:
P1: BreakStuff.App.exe
P2: 1.0.0.0
P3: 56eb2416
P4: BreakStuff.App
P5: 1.0.0.0
P6: 56eb2416
P7: 5
P8: a
P9: FatalError
P10: 

Attached files:
C:\Users\Robert\AppData\Local\Temp\WERE708.tmp.WERInternalMetadata.xml
C:\Users\Robert\AppData\Local\Temp\WERF4B5.tmp.appcompat.txt
C:\ProgramData\Microsoft\Windows\WER\Temp\WERF4D5.tmp.dmp
C:\Users\Robert\AppData\Local\Temp\WERF65D.tmp.WERDataCollectionFailure.txt
C:\ProgramData\Microsoft\Windows\WER\ReportQueue\AppCrash_BreakStuff.App.e_1952fbbdf8ecceaa6e9af5c44339210849f4774_b2bbc455_cab_7634f669\memory.hdmp
WERGenerationLog.txt
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Each &lt;a href=&quot;https://blogs.msdn.microsoft.com/oanapl/2009/01/30/windows-error-reporting-and-clr-integration/&quot;&gt;P holds some exception location information&lt;/a&gt;:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;P1: “BreakStuff.App.exe” = App name or host process&lt;/strong&gt; e.g. your.exe or Outlook.exe for a .NET addin.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;P2: “1.0.0.0” = Version of the executabe&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;P3: “56eb2416” = Timestamp of the executable&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;P4: “BreakStuff.App” = Faulting assembly and module name&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;P5: “1.0.0.0”&lt;/strong&gt; = Version of the faulting module&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;P6: “56eb2416” = Timestamp of the faulting module&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;P7: “5” = MethodDef&lt;/strong&gt; – MethodDef token for the faulting method, after stripping off the high byte. This is the faulting method in your code. &lt;em&gt;Super important!&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;P8: “a” = IL offset&lt;/strong&gt; - in hex, in combination with P7 will it show you the &lt;em&gt;exact position of the exception&lt;/em&gt; in your method.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;P9: “FatalError”&lt;/strong&gt; = Exception type&lt;/p&gt;

&lt;p&gt;P1-P3 should be easy to understand and nothing new to you. If you have a bigger application P4 might lead to the correct namespace/assembly.&lt;/p&gt;

&lt;p&gt;Most important to find the real source is P7 &amp;amp; P8 - I will show you how to read it.&lt;/p&gt;

&lt;h2 id=&quot;p7-finding-the-methoddef-token-with-ildasmexe&quot;&gt;P7: Finding the MethodDef token with ILDASM.exe&lt;/h2&gt;

&lt;p&gt;P7 tells you in which method the exception occurred. The number shown in P7 is the method token, which is the IL representation of your actual method in code. To see the real method name we need a tool.&lt;/p&gt;

&lt;p&gt;As far as I know you could try to use WinDbg, but I was too stupid to use it correctly - ildasm.exe does also work for our use case. To get the method token you need “ildasm.exe”, which is included in the .NET SDK, which is part of the Windows SDK.&lt;/p&gt;

&lt;p&gt;On a Windows 10 machine, with &lt;a href=&quot;https://dev.windows.com/en-us/downloads/windows-10-sdk&quot;&gt;the SDK&lt;/a&gt; installed, you can use this version:&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6 Tools\ildasm.exe
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;For ILDASM it is not important if the actual .NET app is using .NET 4.6 or any other version.&lt;/p&gt;

&lt;p&gt;“ildasm.exe” itself is not a beauty, but works. Now open your assembly from &lt;strong&gt;P4&lt;/strong&gt; with this tool.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://blog.codeinside.eu/assets/md-images/2016-03-23/ildsam.png&quot; alt=&quot;x&quot; title=&quot;using ildsam to get the method token&quot; /&gt;&lt;/p&gt;

&lt;p&gt;To see the tokens, press &lt;strong&gt;CTRL + M&lt;/strong&gt; and search for &lt;strong&gt;P7&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;In my case I see this:&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;Method #2 (06000005) 
-------------------------------------------------------
	MethodName: ButtonBase_OnClick (06000005)
	Flags     : [Private] [HideBySig] [ReuseSlot]  (00000081)
	RVA       : 0x0000208c
	ImplFlags : [IL] [Managed]  (00000000)
	CallCnvntn: [DEFAULT]
	hasThis 
	ReturnType: Void
	2 Arguments
		Argument #1:  Object
		Argument #2:  Class System.Windows.RoutedEventArgs
	2 Parameters
		(1) ParamToken : (08000001) Name : sender flags: [none] (00000000)
		(2) ParamToken : (08000002) Name : e flags: [none] (00000000)
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Take a look at the method description: 0600000 &lt;strong&gt;5&lt;/strong&gt; - the 0600000 is the high byte (whatever that means… - just search for the number, I bet you will find something.)&lt;/p&gt;

&lt;p&gt;&lt;em&gt;BigBasti helped me in the comments to describe the high byte:
Big numbers which need more than one byte to store the value have high bytes (most significant bytes) and low bytes (least significant bytes) - you need to know this to make sure you load the sequence of bytes in the correct order. - Thanks!&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Ok - now we know the actual method. The exception occurs in the ButtonBase_OnClick method!&lt;/p&gt;

&lt;h2 id=&quot;p8-finding-the-exact-position-of-the-faulting-code-with-ilspy&quot;&gt;P8: Finding the exact position of the faulting code with ILSpy&lt;/h2&gt;

&lt;p&gt;Now we need to look at the methods IL. You can use &lt;a href=&quot;http://ilspy.net/&quot;&gt;ILSpy&lt;/a&gt; or any other .NET decompiler (ildasm is not very comfortable, we only used it to get the method name). 
If you choosed ILSpy make sure you switch from the C# view to IL view and go to the faulting method:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://blog.codeinside.eu/assets/md-images/2016-03-23/ilspy-code.png&quot; alt=&quot;x&quot; title=&quot;ILSpy&quot; /&gt;&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;// Method begins at RVA 0x208c
// Code size 11 (0xb)
.maxstack 8

IL_0000: ldstr &quot;I'm dead!&quot;
IL_0005: call void [mscorlib]System.Environment::FailFast(string)
IL_000a: ret
} // end of method MainWindow::ButtonBase_OnClick
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;As you might remember - P8 pointed to “a”, which is the IL_000a instruction.&lt;/p&gt;

&lt;p&gt;Mission accomplished: Exception source found! Yay!&lt;/p&gt;

&lt;h2 id=&quot;big-picture&quot;&gt;Big picture&lt;/h2&gt;

&lt;p&gt;I never thought I had to read the internal IL, but we had one weird case where no log files were generated and we used this trick to get to the source of the exception.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://blog.codeinside.eu/assets/md-images/2016-03-23/bigpicture.png&quot; alt=&quot;x&quot; title=&quot;Big Picture of WER debugging&quot; /&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href=&quot;https://github.com/Code-Inside/Samples/tree/master/2016/BreakStuff&quot;&gt;My breaking Sample Code on GitHub&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Hope this helps!&lt;/p&gt;
</description>
                <link>https://blog.codeinside.eu/2016/03/23/debugging-dotnet-based-windows-error-reports/</link>
                <guid>https://blog.codeinside.eu/2016/03/23/debugging-dotnet-based-windows-error-reports</guid>
                <pubDate>Wed, 23 Mar 2016 23:55:00 +0000</pubDate>
        </item>

        <item>
                <title>XML Autocompletion with AvalonEdit</title>
                <description>
&lt;h2 id=&quot;avalonedit&quot;&gt;AvalonEdit&lt;/h2&gt;

&lt;p&gt;AvalonEdit is a text editor WPF control, used and created by the &lt;a href=&quot;http://www.icsharpcode.net/OpenSource/SD/Default.aspx&quot;&gt;SharpDevelop team&lt;/a&gt;. It comes with some nice features, like code folding support, text highlighting and infrastructure for advanced features like autocompletion.&lt;/p&gt;

&lt;p&gt;Read more about AvalonEdit on the &lt;a href=&quot;http://avalonedit.net/&quot;&gt;offical site&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;To install AvalonEdit, just create a WPF project and install the &lt;a href=&quot;https://www.nuget.org/packages/AvalonEdit/&quot;&gt;AvalonEdit NuGet package&lt;/a&gt;.&lt;/p&gt;

&lt;h2 id=&quot;our-scenario&quot;&gt;Our Scenario&lt;/h2&gt;

&lt;p&gt;We use AvalonEdit to edit XML configurations, but it can be used with any language. This blogpost will only take a look at our XML-scenario.&lt;/p&gt;

&lt;h2 id=&quot;xml-autocomplete-or-intellisense&quot;&gt;XML Autocomplete or “IntelliSense”&lt;/h2&gt;

&lt;p&gt;AvalonEdit only ships with Syntax-Highlighting for XML - but nothing more. To get something like Tag-Autocompletion or even something like “IntelliSense” I had to combine different code pieces and write something new. So… the daily business of any programmer.&lt;/p&gt;

&lt;h3 id=&quot;xml-tag-completion---with-code-from-sharpdevelop-and-xsemmel&quot;&gt;XML Tag-Completion - with Code from SharpDevelop and Xsemmel&lt;/h3&gt;

&lt;p&gt;Modern text editors will autocomplete given XML tags, e.g. if I type the closing element for “&amp;lt;foo” it will create something like “&lt;foo&gt;&lt;/foo&gt;” and set the cursor inside the element.
To get to this feature we need to know which XML tag we are currently try to write - this issue can be solved with some magic RegEx0.&lt;/p&gt;

&lt;p&gt;The good part: This is already a solved problem. I discovered a very clever XmlParser on the &lt;strong&gt;&lt;a href=&quot;https://github.com/icsharpcode/SharpDevelop/tree/master/src/AddIns/DisplayBindings/XmlEditor&quot;&gt;SharpDevelop GitHub Repo&lt;/a&gt;&lt;/strong&gt; and another one from the &lt;strong&gt;&lt;a href=&quot;https://xsemmel.codeplex.com/&quot;&gt;Xsemmel Project&lt;/a&gt;&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;I use code from both projects and integrated it in my sample project. And I hope I didn’t break the license by doing it - if yes I did it unintentional. Each code part is marked with the source and the copyright notes are included as well.&lt;/p&gt;

&lt;p&gt;Anyway: &lt;strong&gt;Huge credits are going to both projects.&lt;/strong&gt;&lt;/p&gt;

&lt;h3 id=&quot;what-i-get-from-those-libraries&quot;&gt;What I get from those libraries?&lt;/h3&gt;

&lt;p&gt;Both libraries are clever enough to parse XML - or even “invalid” XML, and return the current position inside the XML tree. The code from Xsemmel also helped me with the “pure” tag completion.&lt;/p&gt;

&lt;p&gt;My merged XmlParser will return me the needed information for autocompletion or even “IntelliSense”-like features.&lt;/p&gt;

&lt;h3 id=&quot;xml-intellisense---whats-the-source-of-the-intellisense&quot;&gt;XML “IntelliSense” - What’s the source of the “IntelliSense”?&lt;/h3&gt;

&lt;p&gt;To present some clever autocomplete actions, we need a source for this information. The good thing about XML is, that there is a huge range of related standards around it. The idea is simple:&lt;/p&gt;

&lt;p&gt;Using an &lt;strong&gt;existing XML Schema&lt;/strong&gt; should do the trick. I already blogged about it &lt;strong&gt;&lt;a href=&quot;http://blog.codeinside.eu/2016/03/06/parsing-xml-schemas-in-dotnet/&quot;&gt;here&lt;/a&gt;&lt;/strong&gt;.&lt;/p&gt;

&lt;h3 id=&quot;putting-those-pieces-together&quot;&gt;Putting those pieces together:&lt;/h3&gt;

&lt;p&gt;I created a WPF project, included the AvalonEdit NuGet package and the code portions I already mentioned. The performance in the animation is a bit slow, because I wanted to show you what the XmlParser is doing in the background - this can be seen at the bottom of the application.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://blog.codeinside.eu/assets/md-images/2016-03-13/xmleditor.gif&quot; alt=&quot;x&quot; title=&quot;AvalonEdit with XML Autocompletion&quot; /&gt;.&lt;/p&gt;

&lt;p&gt;You don’t need to “query” the document everytime you change the cursor - so in real life the performance hit is not very noticeable.&lt;/p&gt;

&lt;p&gt;As I already mentioned in the XSD-blogpost: XML Namespaces will not work with this implementation. As far as I know the SharpDevelop code should understand namespaces, but at least my XSD parser is not smart enough.&lt;/p&gt;

&lt;h3 id=&quot;the-logic&quot;&gt;The logic&lt;/h3&gt;

&lt;p&gt;The most interesting logic happens in the &lt;a href=&quot;https://github.com/Code-Inside/Samples/blob/master/2016/XmlIntelliSense/XmlIntelliSense.App/MainWindow.xaml.cs#L40&quot;&gt;TextEntered-EventHandler&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;The “&amp;gt;” and “/” key is interesting for the simple tag autocompletion. The “XsdParser”-Result is used when you hit the “&amp;lt;” key or “ “ as long as you are inside a tag for attribute autocompletion.&lt;/p&gt;

&lt;h3 id=&quot;good-enough&quot;&gt;“Good enough”&lt;/h3&gt;

&lt;p&gt;My implementation is far away from perfection, but should be good enough for most simple cases. As I already mentioned, the heavy lifting is done by code from SharpDevelop or Xsemmel. My sample is self-contained and only relies on the AvalonEdit NuGet package and the standard WPF.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href=&quot;https://github.com/Code-Inside/Samples/tree/master/2016/XmlIntelliSense&quot;&gt;Full Sample Code on GitHub&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Hope this helps!&lt;/p&gt;
</description>
                <link>https://blog.codeinside.eu/2016/03/13/xml-autocompletion-with-avalonedit/</link>
                <guid>https://blog.codeinside.eu/2016/03/13/xml-autocompletion-with-avalonedit</guid>
                <pubDate>Sun, 13 Mar 2016 22:00:00 +0000</pubDate>
        </item>

        <item>
                <title>Parsing XML Schemas in .NET</title>
                <description>
&lt;h2 id=&quot;xml-schemas&quot;&gt;XML Schemas&lt;/h2&gt;

&lt;p&gt;XML can be very verbose and seems to be old-fashioned, but the good part around XML is, that there is a hugh pile of standardized mechanics around it. 
To query XML documents you can use &lt;a href=&quot;https://en.wikipedia.org/wiki/XPath&quot;&gt;XPath&lt;/a&gt;, for transforming &lt;a href=&quot;https://en.wikipedia.org/wiki/XSLT&quot;&gt;XSLT&lt;/a&gt; and for validation &lt;strong&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/XML_Schema_(W3C)&quot;&gt;XML Schemas&lt;/a&gt;&lt;/strong&gt; or in short a “XSD” (XML Schema Definition).&lt;/p&gt;

&lt;h2 id=&quot;parsing-the-xsd-tree&quot;&gt;Parsing the XSD Tree&lt;/h2&gt;

&lt;p&gt;A XSD is just a XML document itself that describes the your valid XML document tree. Because its just a normal XML document (with a fancy XML-namespace), you could parse it via the normal XDocument, but things are way easier for you when you look at the &lt;a href=&quot;https://msdn.microsoft.com/de-de/library/system.xml.schema(v=vs.110).aspx&quot;&gt;System.Xml.Schema-Namespace&lt;/a&gt;.&lt;/p&gt;

&lt;h2 id=&quot;code&quot;&gt;Code&lt;/h2&gt;

&lt;p&gt;The basic code was taken from &lt;a href=&quot;https://msdn.microsoft.com/en-us/library/ms255932(v=vs.110).aspx&quot;&gt;the MSDN&lt;/a&gt; and I added the recursive part to get all possible elements.&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;/// &amp;lt;summary&amp;gt;
/// Code based on https://msdn.microsoft.com/en-us/library/ms255932(v=vs.110).aspx
/// &amp;lt;/summary&amp;gt;
class Program
{
    public static void AnalyseSchema(XmlSchemaSet set)
    {
        // Retrieve the compiled XmlSchema object from the XmlSchemaSet
        // by iterating over the Schemas property.
        XmlSchema customerSchema = null;
        foreach (XmlSchema schema in set.Schemas())
        {
            customerSchema = schema;
        }

        // Iterate over each XmlSchemaElement in the Values collection
        // of the Elements property.
        foreach (XmlSchemaElement element in customerSchema.Elements.Values)
        {
            RecursiveElementAnalyser(&quot; &quot;, element);
        }

    }

    public static void RecursiveElementAnalyser(string prefix, XmlSchemaElement element)
    {
        string elementName = prefix + element.Name;

        string dataType = element.ElementSchemaType.TypeCode.ToString();

        Console.WriteLine(elementName + &quot; (&quot; + dataType + &quot;)&quot;);

        // Get the complex type of the Customer element.
        XmlSchemaComplexType complexType = element.ElementSchemaType as XmlSchemaComplexType;

        if (complexType != null)
        {
            // If the complex type has any attributes, get an enumerator 
            // and write each attribute name to the console.
            if (complexType.AttributeUses.Count &amp;gt; 0)
            {
                IDictionaryEnumerator enumerator =
                    complexType.AttributeUses.GetEnumerator();

                while (enumerator.MoveNext())
                {
                    XmlSchemaAttribute attribute =
                        (XmlSchemaAttribute)enumerator.Value;

                    string attrDataType = attribute.AttributeSchemaType.TypeCode.ToString();

                    string attrName = string.Format(prefix + &quot;(Attr:: {0}({1}))&quot;, attribute.Name, attrDataType);

                    Console.WriteLine(attrName);
                }
            }

            // Get the sequence particle of the complex type.
            XmlSchemaSequence sequence = complexType.ContentTypeParticle as XmlSchemaSequence;

            if (sequence != null)
            {
                // Iterate over each XmlSchemaElement in the Items collection.
                foreach (var childElement in sequence.Items)
                {
                    var xmlSchemaElement = childElement as XmlSchemaElement;
                    if (xmlSchemaElement != null)
                    {
                        RecursiveElementAnalyser(&quot; &quot; + prefix, xmlSchemaElement);
                    }
                    else
                    {
                        // support for XmlSchemaChoise element list
                        var choice = childElement as XmlSchemaChoice;
                        if (choice != null)
                        {
                            foreach (var choiceElement in choice.Items)
                            {
                                var xmlChoiceSchemaElement = choiceElement as XmlSchemaElement;
                                if (xmlChoiceSchemaElement != null)
                                {
                                    RecursiveElementAnalyser(&quot; &quot; + prefix, xmlChoiceSchemaElement);
                                }
                            }
                        }
                    }
                }
            }
        }
    }

    static void Main(string[] args)
    {
        XmlSchemaSet schemas = new XmlSchemaSet();
        schemas.Add(&quot;&quot;, XmlReader.Create(new StringReader(File.ReadAllText(&quot;Schema.xsd&quot;))));
        schemas.Compile();
        AnalyseSchema(schemas);
        Console.ReadLine();
    }
}
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Output:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://blog.codeinside.eu/assets/md-images/2016-03-06/xsd.png&quot; alt=&quot;x&quot; title=&quot;XSD Tree from Code&quot; /&gt;&lt;/p&gt;

&lt;p&gt;You should see the possible XML elements, attributes and their datatypes, but you have access to all specified schema information from the XSD that you want.&lt;/p&gt;

&lt;h2 id=&quot;xml-namespaces&quot;&gt;XML Namespaces&lt;/h2&gt;

&lt;p&gt;XML namespaces are powerful, but can also be pretty complicated for everyone who needs to parse your XML. I guess you could put some evil XML namespaces inside the XSD and things will break with my code. 
Just be aware of this issue if you are dealing with namespaces.&lt;/p&gt;

&lt;h2 id=&quot;visual-studio-tooling&quot;&gt;Visual Studio Tooling&lt;/h2&gt;

&lt;p&gt;I discovered that Visual Studio ships with a pretty nice XSD editor. But you don’t need to craft the XSD by hand,there are many tools out there that can generate XSDs based on existing XML documents.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://blog.codeinside.eu/assets/md-images/2016-03-06/vs.png&quot; alt=&quot;x&quot; title=&quot;Visual Studio XSD Tree&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;sample-xsd&quot;&gt;Sample XSD&lt;/h2&gt;

&lt;p&gt;I added the XSD Sample from the &lt;a href=&quot;https://msdn.microsoft.com/en-us/library/bb675181.aspx&quot;&gt;MSDN&lt;/a&gt; in the demo project. If you found an issue, just let me know.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href=&quot;https://github.com/Code-Inside/Samples/tree/master/2016/XsdParser&quot;&gt;Full Sample Code on GitHub&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Hope this helps!&lt;/p&gt;
</description>
                <link>https://blog.codeinside.eu/2016/03/06/parsing-xml-schemas-in-dotnet/</link>
                <guid>https://blog.codeinside.eu/2016/03/06/parsing-xml-schemas-in-dotnet</guid>
                <pubDate>Sun, 06 Mar 2016 08:15:00 +0000</pubDate>
        </item>

        <item>
                <title>Using FontAwesome in UWP apps</title>
                <description>
&lt;h2 id=&quot;fontawesome-in-wpf-and-fonts-in-uwp&quot;&gt;FontAwesome in WPF and Fonts in UWP&lt;/h2&gt;

&lt;p&gt;I blogged about &lt;a href=&quot;http://blog.codeinside.eu/2015/01/07/using-fontawesome-with-wpf/&quot;&gt;how to use FontAwesome in WPF&lt;/a&gt; last year and wrote a short blogpost about the nice &lt;a href=&quot;http://blog.codeinside.eu/2016/01/31/working-with-fonticons-in-uwp/&quot;&gt;FontIcon class in UWP&lt;/a&gt;. 
With the help of the FontIcon class I could include the FontAwesome glyphs, but working with the unicodes is not very dev friendly.&lt;/p&gt;

&lt;h2 id=&quot;bringing-fontawesomewpf-to-the-uwp-universe---oss-rocks&quot;&gt;Bringing FontAwesome.WPF to the UWP universe - OSS rocks!&lt;/h2&gt;

&lt;p&gt;The goal was pretty clear: I would like to have the excellent FontAwesome.WPF NuGet package working on UWP. 
So I created an issue on the &lt;a href=&quot;https://github.com/charri/Font-Awesome-WPF/issues/230&quot;&gt;FontAwesome.WPF GitHub repo&lt;/a&gt; and some contributions later the &lt;a href=&quot;http://www.nuget.org/packages/FontAwesome.UWP/&quot;&gt;FontAwesome.UWP NuGet package&lt;/a&gt; was born.&lt;/p&gt;

&lt;p&gt;_Thanks to everyone who was involved!__&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://blog.codeinside.eu/assets/md-images/2016-03-05/nuget.png&quot; alt=&quot;x&quot; title=&quot;FontAwesome.UWP NuGet package&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;using-fontawesome-in-uwp&quot;&gt;Using FontAwesome in UWP…&lt;/h2&gt;

&lt;p&gt;As you might imaging - the usage is now pretty easy after including the FontAwesome.UWP NuGet package.&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&amp;lt;Page
    x:Class=&quot;UwpDemo.MainPage&quot;
    xmlns=&quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;
    xmlns:x=&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot;
    xmlns:local=&quot;using:UwpDemo&quot;
    xmlns:d=&quot;http://schemas.microsoft.com/expression/blend/2008&quot;
    xmlns:mc=&quot;http://schemas.openxmlformats.org/markup-compatibility/2006&quot;
    xmlns:fa=&quot;using:FontAwesome.UWP&quot;
    mc:Ignorable=&quot;d&quot;&amp;gt;

    &amp;lt;Grid Background=&quot;{ThemeResource ApplicationPageBackgroundThemeBrush}&quot;&amp;gt;
        &amp;lt;fa:FontAwesome Icon=&quot;Flag&quot; FontSize=&quot;90&quot; Foreground=&quot;Chartreuse&quot; HorizontalAlignment=&quot;Center&quot; /&amp;gt;
    &amp;lt;/Grid&amp;gt;
&amp;lt;/Page&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Result:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://blog.codeinside.eu/assets/md-images/2016-03-05/demo.png&quot; alt=&quot;x&quot; title=&quot;FontAwesome on UWP&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Pretty nice and it was a good collaboration - big thanks to &lt;a href=&quot;https://github.com/charri&quot;&gt;Thomas Charriere&lt;/a&gt;, who is the maintainer behind the project.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href=&quot;https://github.com/Code-Inside/Samples/tree/master/2016/UwpFontAwesome/UwpDemo&quot;&gt;Demo Project on our GitHub Sample repo&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Hope this helps!&lt;/p&gt;
</description>
                <link>https://blog.codeinside.eu/2016/03/05/using-fontawesome-in-uwp-apps/</link>
                <guid>https://blog.codeinside.eu/2016/03/05/using-fontawesome-in-uwp-apps</guid>
                <pubDate>Sat, 05 Mar 2016 23:55:00 +0000</pubDate>
        </item>

        <item>
                <title>Using Travis CI for GitHub Pages builds</title>
                <description>
&lt;p&gt;&lt;img src=&quot;https://blog.codeinside.eu/assets/md-images/2016-03-03/travisci.png&quot; alt=&quot;x&quot; title=&quot;Travis CI Logo&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;short-recap-github-pages--jekyll&quot;&gt;Short recap: GitHub Pages &amp;amp; Jekyll&lt;/h2&gt;

&lt;p&gt;This blog is powered by &lt;a href=&quot;https://pages.github.com/&quot;&gt;GitHub Pages&lt;/a&gt;, which uses &lt;a href=&quot;https://jekyllrb.com/&quot;&gt;Jekyll&lt;/a&gt; in the background. Jekyll is a static website generator, which means that this page is “build” and has no server-side rendering logic when you hit the page - it’s pure static HTML, CSS and JS.&lt;/p&gt;

&lt;p&gt;You could run Jekyll on your local box and publish the sites to GitHub Pages - I prefer a pure “GitHub Page”-based model. Actually I don’t even have Jekyll installed on my PC. &lt;a href=&quot;http://blog.codeinside.eu/2014/09/13/How-We-Moved-From-Wordpress-To-Jekyll-On-Windows/&quot;&gt;I wrote a small blogpost about running Jekyll on Windows if you are interested&lt;/a&gt;.&lt;/p&gt;

&lt;h2 id=&quot;travis-cihttptravis-ciorg&quot;&gt;&lt;strong&gt;&lt;a href=&quot;http://travis-ci.org&quot;&gt;Travis CI&lt;/a&gt;&lt;/strong&gt;&lt;/h2&gt;

&lt;p&gt;As you might imaging - during the build stuff can break. In this case GitHub will send you a very short “error” email via mail. To get a more detailed report, &lt;a href=&quot;https://help.github.com/articles/viewing-jekyll-build-error-messages/&quot;&gt;GitHub suggests to use Travis CI&lt;/a&gt;, which is the main topic of this blogpost.&lt;/p&gt;

&lt;h2 id=&quot;travis-ci-setup&quot;&gt;Travis CI Setup&lt;/h2&gt;

&lt;p&gt;The basic setup is pretty simple, but I had some issues - the last step is not very good documented - and that’s why I decided to blog about it.&lt;/p&gt;

&lt;h3 id=&quot;login-to-travis-ci-and-sync-your-account&quot;&gt;1. Login to Travis CI and “sync” your account&lt;/h3&gt;

&lt;p&gt;You will need to login to Travis CI with your GitHub account. This will kick in a “sync”. After a short period you should see all your repositories on your profile page:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://blog.codeinside.eu/assets/md-images/2016-03-03/travisci-1.png&quot; alt=&quot;x&quot; title=&quot;Travis CI Profile Page&quot; /&gt;&lt;/p&gt;

&lt;h3 id=&quot;enable-the-desired-project-on-travis-ci&quot;&gt;2. Enable the desired project on Travis CI&lt;/h3&gt;

&lt;p&gt;Just flip on the switch on your profil page for the desired project and Travis will watch the repository for any changes.&lt;/p&gt;

&lt;h3 id=&quot;adding-a-gemfile-and-a-travisyml-file-to-your-project&quot;&gt;3. Adding a Gemfile and a .travis.yml file to your project&lt;/h3&gt;

&lt;p&gt;To build GitHub Page stuff via Travis you will need a &lt;a href=&quot;https://github.com/Code-Inside/Blog/blob/gh-pages/Gemfile&quot;&gt;Gemfile&lt;/a&gt; and a &lt;a href=&quot;https://github.com/Code-Inside/Blog/blob/gh-pages/.travis.yml&quot;&gt;.tarvis.yml&lt;/a&gt;.
My current files are pretty basic and a copy from the GitHub Pages Help site, with &lt;strong&gt;one important exception&lt;/strong&gt;…&lt;/p&gt;

&lt;h3 id=&quot;targeting-the-correct-branch&quot;&gt;4. Targeting the correct branch&lt;/h3&gt;

&lt;p&gt;The last step is to ensure that Travis CI will search for the correct branch. In my case, I only have the “gh-pages” branch, but Travis CI will look for a “master” branch.&lt;/p&gt;

&lt;p&gt;To configure Travis CI to use the correct “gh-pages” branch you will need this config section inside the .yml:&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;branches:
 only:
 - gh-pages  
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;After this setup you should already see the finished Travis CI build:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://blog.codeinside.eu/assets/md-images/2016-03-03/travisci-2.png&quot; alt=&quot;x&quot; title=&quot;Travis CI Build Page&quot; /&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Important:&lt;/strong&gt; The output of the build will not be copied over to GitHub - at this stage it is just a “safety net”. If you want to publish from Travis CI, there are many blogposts out there that describe this topic.&lt;/p&gt;

&lt;p&gt;Hope this helps!&lt;/p&gt;
</description>
                <link>https://blog.codeinside.eu/2016/03/03/using-travis-ci-for-github-page-builds/</link>
                <guid>https://blog.codeinside.eu/2016/03/03/using-travis-ci-for-github-page-builds</guid>
                <pubDate>Thu, 03 Mar 2016 23:30:00 +0000</pubDate>
        </item>

        <item>
                <title>Pretty Print XML in .NET</title>
                <description>
&lt;h2 id=&quot;pretty-print&quot;&gt;Pretty Print&lt;/h2&gt;

&lt;p&gt;The term “pretty print” describes that a document is more or less human readable formatted. So instead of this:&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&amp;lt;Foo&amp;gt;&amp;lt;Bar&amp;gt;&amp;lt;Buzz&amp;gt;&amp;lt;/Buzz&amp;gt;&amp;lt;/Bar&amp;gt;&amp;lt;/Foo&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;You might want to get this:&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&amp;lt;Foo&amp;gt;
  &amp;lt;Bar&amp;gt;
    &amp;lt;Buzz&amp;gt;&amp;lt;/Buzz&amp;gt;
  &amp;lt;/Bar&amp;gt;
&amp;lt;/Foo&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Many editors support this feature - but we want to do it in code.&lt;/p&gt;

&lt;h2 id=&quot;pretty-print-xml-with-net&quot;&gt;Pretty Print XML with .NET&lt;/h2&gt;

&lt;p&gt;The code is really simple, because XDocument does the heavy lifting for us.&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;var xDocument = XDocument.Parse(input);
string formattedXml = xDocument.ToString();

// Force XML Declaration if present
if (xDocument.Declaration != null)
{
  formattedXml = xDocument.Declaration + Environment.NewLine + formattedXml;
}
return formattedXml;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;This should work in most cases - there might be some issues with comments or maybe special XML chars. If you have a better idea, please let me know.&lt;/p&gt;

&lt;p&gt;Hope this helps!&lt;/p&gt;
</description>
                <link>https://blog.codeinside.eu/2016/02/28/pretty-print-xml-in-dotnet/</link>
                <guid>https://blog.codeinside.eu/2016/02/28/pretty-print-xml-in-dotnet</guid>
                <pubDate>Sun, 28 Feb 2016 20:00:00 +0000</pubDate>
        </item>

        <item>
                <title>ExpensiveMeeting - a Universal Windows Platform OSS app using Template10</title>
                <description>
&lt;h2 id=&quot;expensivemeeting&quot;&gt;ExpensiveMeeting&lt;/h2&gt;

&lt;p&gt;The app - which is just a fun project and shouldn’t be taken too seriously -  is like a stopwatch for meetings. 
But instead of the pure time it shows you also the burned money for your meeting, because time is money, right?&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://blog.codeinside.eu/assets/md-images/2016-02-28/app.png&quot; alt=&quot;x&quot; title=&quot;ExpensiveMeeting app&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Don’t worry: The app is free and no ads are shown.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href=&quot;https://www.microsoft.com/store/apps/9NBLGGH5PVW9&quot;&gt;Windows Store Download&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2 id=&quot;behind-the-scenes-universal-windows-platfrom-uwp&quot;&gt;Behind the scenes: Universal Windows Platfrom (UWP)&lt;/h2&gt;

&lt;p&gt;The app itself is a UWP app, which means it runs on Windows 10, Windows IoT, Windows Mobile 10 (or is it Phone?) and maybe in the future on Xbox One. 
To see the app running on my phone, without touching the code at all, was pure fun. I really like the UWP approach.&lt;/p&gt;

&lt;h2 id=&quot;behind-the-scenes-template10&quot;&gt;Behind the scenes: Template10&lt;/h2&gt;

&lt;p&gt;Starting from scratch can be fun, but to shorten the development time I used the nice &lt;strong&gt;&lt;a href=&quot;http://aka.ms/template10&quot;&gt;Template10&lt;/a&gt;&lt;/strong&gt; template, which gives me the typical hamburger app layout. 
The project can be found on &lt;a href=&quot;https://github.com/Windows-XAML/Template10&quot;&gt;GitHub&lt;/a&gt; and has a very active community.&lt;/p&gt;

&lt;h2 id=&quot;behind-the-scenes-all-code-on-github&quot;&gt;Behind the scenes: All Code on GitHub&lt;/h2&gt;

&lt;p&gt;I decided to work in the open on &lt;strong&gt;&lt;a href=&quot;https://github.com/Code-Inside/ExpensiveMeeting&quot;&gt;GitHub&lt;/a&gt;&lt;/strong&gt;, so if you are interested on the actual code, just take a look and do whatever you want to do.&lt;/p&gt;

&lt;p&gt;If you have ideas or found bugs I would appreciate your help:
Just create an &lt;strong&gt;&lt;a href=&quot;https://github.com/Code-Inside/ExpensiveMeeting/issues&quot;&gt;issue&lt;/a&gt;&lt;/strong&gt; or send a pull request.&lt;/p&gt;
</description>
                <link>https://blog.codeinside.eu/2016/02/28/expensivemeeting-a-uwp-oss-app-using-template10/</link>
                <guid>https://blog.codeinside.eu/2016/02/28/expensivemeeting-a-uwp-oss-app-using-template10</guid>
                <pubDate>Sun, 28 Feb 2016 17:00:00 +0000</pubDate>
        </item>

        <item>
                <title>Shipping Visual C++ 2015 redistributable DLLs with your app or how to do an app-local deployment</title>
                <description>
&lt;h2 id=&quot;small-warning-im-not-a-c-dev&quot;&gt;Small warning: I’m not a C++ dev&lt;/h2&gt;

&lt;p&gt;We use VC++ just for a very small part of our application, but this part needs the VC++ 2015 runtime “installed” on the client, but we don’t want the UAC install dialog. 
So - let’s take a look how we can solve this problem.&lt;/p&gt;

&lt;p&gt;And if I write something stupid here - please let me know.&lt;/p&gt;

&lt;h2 id=&quot;ways-to-deploy-vc-2015&quot;&gt;Ways to deploy VC++ 2015&lt;/h2&gt;

&lt;p&gt;There are three ways to deploy the runtime:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Install it via the standalone VCRedist installer. This is probably the most known way, but requires elevated permissions because the file will be installed to System32.&lt;/li&gt;
  &lt;li&gt;Install it via a merge module. If you already have an installer, you can include the needed .msm files in your own installer, but this will also require elevated permissions because the files will be also installed to System32.&lt;/li&gt;
  &lt;li&gt;Deploy it with your app as app-local deployment. We will cover this in this blogpost, because &lt;strong&gt;we don’t want to touch anything that needs elevated permissions&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you want to read more about the first two ways, the &lt;a href=&quot;https://msdn.microsoft.com/en-us/library/ms235299.aspx&quot;&gt;MSDN&lt;/a&gt; might be a good place to start.&lt;/p&gt;

&lt;h2 id=&quot;app-local-deployment-of-the-vc-2015-runtime&quot;&gt;App-Local deployment of the VC++ 2015 runtime&lt;/h2&gt;

&lt;p&gt;All what you need is already (if you are using Windows 10 &amp;amp; Visual Studio 2015) installed on your dev machine. Otherwise you will need to download the Windows 10 SDK and Visual Studio 2015.&lt;/p&gt;

&lt;p&gt;Depending on your application, you will need to ship &lt;strong&gt;all&lt;/strong&gt; dlls from the following folders with your application (= the dll/exe/whatever that needs the runtime) :&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;x86 applications&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;C:\Program Files (x86)\Windows Kits\10\Redist\ucrt\DLLs\x86&lt;/li&gt;
  &lt;li&gt;C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\redist\x86\Microsoft.VC140.CRT&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;x64 applications&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;C:\Program Files (x86)\Windows Kits\10\Redist\ucrt\DLLs\x64&lt;/li&gt;
  &lt;li&gt;C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\redist\x64\Microsoft.VC140.CRT&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The &lt;a href=&quot;https://blogs.msdn.microsoft.com/vcblog/2015/03/03/introducing-the-universal-crt/&quot;&gt;“Universal CRT”&lt;/a&gt; consists of many dlls and all are required. You have to copy them to your application folder and it should just work.&lt;/p&gt;

&lt;p&gt;As far as I know, if a user has installed the runtime via VCRedist or the merge modules the files inside System32 will be picked.&lt;/p&gt;

&lt;p&gt;I found this solution &lt;a href=&quot;https://social.msdn.microsoft.com/Forums/sqlserver/en-US/d8f0acf9-5d4c-408d-8cea-c201fd61b9b7/local-deployment-of-redist-dlls-no-longer-works-with-visual-studio-2015?forum=visualstudiogeneral&quot;&gt;here&lt;/a&gt; and it seems to work just fine - no UAC prompt. Yay.&lt;/p&gt;

&lt;p&gt;Hope this helps.&lt;/p&gt;
</description>
                <link>https://blog.codeinside.eu/2016/02/23/ship-vcredist-2015-with-your-app-aka-applocal-deploy/</link>
                <guid>https://blog.codeinside.eu/2016/02/23/ship-vcredist-2015-with-your-app-aka-applocal-deploy</guid>
                <pubDate>Tue, 23 Feb 2016 22:45:00 +0000</pubDate>
        </item>

        <item>
                <title>Working with FontIcons in UWP</title>
                <description>
&lt;h2 id=&quot;fonticons-in-uwp&quot;&gt;FontIcons in UWP&lt;/h2&gt;

&lt;p&gt;Microsoft ships one builtin UWP (Universal Windows Platform) &lt;a href=&quot;https://msdn.microsoft.com/EN-US/library/windows/apps/windows.ui.xaml.controls.symbol.aspx&quot;&gt;&lt;strong&gt;SymbolIcon&lt;/strong&gt;&lt;/a&gt; class.&lt;/p&gt;

&lt;p&gt;The good thing about such FontIcons is, that you can scale and change the appearances very nice and don’t need a bunch of image assets for your icons.&lt;/p&gt;

&lt;p&gt;The down side is, that those icons are just a font… so no multicolor option.&lt;/p&gt;

&lt;p&gt;The builtin SymbolIcon usage is pretty easy:&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&amp;lt;SymbolIcon Symbol=&quot;Accept&quot; /&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;h2 id=&quot;using-fonticon-to-serve-other-font-eg-fontawesome&quot;&gt;Using FontIcon to serve other font e.g. FontAwesome&lt;/h2&gt;

&lt;p&gt;Microsoft ships another simple class, the &lt;a href=&quot;https://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.xaml.controls.fonticon.glyph&quot;&gt;&lt;strong&gt;FontIcon&lt;/strong&gt;&lt;/a&gt; class.&lt;/p&gt;

&lt;h3 id=&quot;including-the-font&quot;&gt;Including the font&lt;/h3&gt;

&lt;p&gt;You will need the actual Font-File, e.g. a .otf file. This file must be included in your project as &lt;strong&gt;Content&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;After that the usage is pretty simple if you know the correct syntax:&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&amp;lt;FontIcon FontFamily=&quot;./fontawesome.otf#FontAwesome&quot; Glyph=&quot;&amp;amp;#xf0b2;&quot;&amp;gt;&amp;lt;/FontIcon&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;The Glyph-Property is the HexCode for the target char.&lt;/p&gt;

&lt;p&gt;Pretty important, but I’m not a Font-Expert, so maybe this is “normal”
- The #FontAwesome must be set.
- In XAML the Glyph must be in this form&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&quot;&amp;amp;#xf0b2;&quot;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;ul&gt;
  &lt;li&gt;
    &lt;p&gt;From Code, the value must be unicode, e.g.&lt;/p&gt;

    &lt;p&gt;Test.Glyph = “\uf0b2”;&lt;/p&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Instead of the “./…” path syntax you could also use something like this:&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&amp;lt;FontIcon FontFamily=&quot;ms-appx:///fontawesome.otf#FontAwesome&quot; Glyph=&quot;&amp;amp;#xf0b2;&quot;&amp;gt;&amp;lt;/FontIcon&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;h2 id=&quot;result&quot;&gt;Result&lt;/h2&gt;

&lt;p&gt;The result is hopefully that you see the correct icon… right?&lt;/p&gt;

&lt;p&gt;BTW, we try to bring &lt;a href=&quot;https://github.com/charri/Font-Awesome-WPF/issues/23&quot;&gt;FontAwesome to UWP&lt;/a&gt; with a simple NuGet package.&lt;/p&gt;

&lt;p&gt;And thanks to &lt;a href=&quot;https://twitter.com/Alex_Witkowski/status/692134058051178502&quot;&gt;Alexander Witkowski&lt;/a&gt; for the suggestion of the FontIcon class - I didn’t know that this is part of the SDK.&lt;/p&gt;

&lt;h2 id=&quot;demo-code&quot;&gt;Demo-Code&lt;/h2&gt;

&lt;p&gt;I made a pretty small UWP Demo, which can be viewed on our &lt;a href=&quot;https://github.com/Code-Inside/Samples/tree/master/2016/FontAwesomeDemo&quot;&gt;Samples-Repo&lt;/a&gt;.&lt;/p&gt;
</description>
                <link>https://blog.codeinside.eu/2016/01/31/working-with-fonticons-in-uwp/</link>
                <guid>https://blog.codeinside.eu/2016/01/31/working-with-fonticons-in-uwp</guid>
                <pubDate>Sun, 31 Jan 2016 20:30:00 +0000</pubDate>
        </item>

        <item>
                <title>Serving embedded resources with ASP.NET WebApi</title>
                <description>
&lt;h2 id=&quot;embedded-files-why&quot;&gt;Embedded files? Why?&lt;/h2&gt;

&lt;p&gt;In a normal Web-Application all files are somehow stored as files in the app directory, but sometimes it could be handy to embed those files.&lt;/p&gt;

&lt;p&gt;One scenario could be that you have a “library”, which can be integrated in a larger application. If you don’t want to pull over all files and you &lt;strong&gt;just want to expose a single assembly&lt;/strong&gt; (for example as NuGet package) embedded resources might come handy.&lt;/p&gt;

&lt;h2 id=&quot;demo-application&quot;&gt;Demo-Application&lt;/h2&gt;

&lt;p&gt;My demo application is a simple ConsoleApp, which a selfhosting WebAPI and two Controllers (Demo and Pages):&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://blog.codeinside.eu/assets/md-images/2015-12-31/embeddedresources-structure.png&quot; alt=&quot;x&quot; title=&quot;VS Structure&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Important is, that my “target” html and css file are marked as &lt;strong&gt;Embedded Resource&lt;/strong&gt;.&lt;/p&gt;

&lt;h2 id=&quot;routing&quot;&gt;Routing&lt;/h2&gt;

&lt;p&gt;In my sample I have created on “PageController”, which accepts all requests that seems to target the embedded files.&lt;/p&gt;

&lt;p&gt;Registration:&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;public class Startup
{
    public void Configuration(IAppBuilder appBuilder)
    {
        HttpConfiguration config = new HttpConfiguration();

        config.MapHttpAttributeRoutes();

        config.Routes.MapHttpRoute(
            name: &quot;ApiV1&quot;,
            routeTemplate: &quot;api/v1/{controller}/{id}&quot;,
            defaults: new { id = RouteParameter.Optional }
            );

        config.Routes.MapHttpRoute(
           name: &quot;PageController&quot;,
           routeTemplate: &quot;{*anything}&quot;,
           defaults: new { controller = &quot;Page&quot;, uri = RouteParameter.Optional });

        appBuilder.UseWebApi(config);
    }

}
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;h2 id=&quot;the-pagecontroller&quot;&gt;The “PageController”&lt;/h2&gt;

&lt;p&gt;This controller will try to read the HTTP GET PathAndQuery and will look inside the assembly resources for something with the same name.&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;public class PageController : ApiController
{
    private const string ResourcePath = &quot;SelfHostWithBetterRouting.Pages{0}&quot;;

    public static string GetStreamContent(string folderAndFileInProjectPath)
    {
        var asm = Assembly.GetExecutingAssembly();
        var resource = string.Format(ResourcePath, folderAndFileInProjectPath);

        using (var stream = asm.GetManifestResourceStream(resource))
        {
            if (stream != null)
            {
                var reader = new StreamReader(stream);
                return reader.ReadToEnd();
            }
        }
        return String.Empty;
    }


    public HttpResponseMessage Get()
    {
        var virtualPathRoot = this.Request.GetRequestContext().VirtualPathRoot;
        string filename = this.Request.RequestUri.PathAndQuery;

        // remove SERVER/appname from request to get the relative filename
        if (virtualPathRoot != &quot;/&quot;)
        {
            filename = filename.ToLowerInvariant().Replace(virtualPathRoot.ToLowerInvariant(), string.Empty);
        }
        
        // input as /page-assets/js/scripts.js
        if (filename == &quot;/&quot; || filename == &quot;&quot;)
        {
            filename = &quot;.index.html&quot;;
        }

        // folders will be seen as &quot;namespaces&quot; - so replace / with the .
        filename = filename.Replace(&quot;/&quot;, &quot;.&quot;);
        // resources can't be named with -, so it will be replaced with a _
        filename = filename.Replace(&quot;-&quot;, &quot;_&quot;);

        var mimeType = System.Web.MimeMapping.GetMimeMapping(filename);

        var fileStreamContent = GetStreamContent(filename);

        if (string.IsNullOrWhiteSpace(fileStreamContent))
        {
            throw new Exception(string.Format(&quot;Can't find embedded file for '{0}'&quot;, filename));
        }

        if (virtualPathRoot != &quot;/&quot;)
        {
            fileStreamContent = fileStreamContent.Replace(&quot;~/&quot;, virtualPathRoot + &quot;/&quot;);
        }
        else
        {
            fileStreamContent = fileStreamContent.Replace(&quot;~/&quot;, virtualPathRoot);
        }

        var response = new HttpResponseMessage();
        response.Content = new StringContent(fileStreamContent);
        response.Content.Headers.ContentType = new MediaTypeHeaderValue(mimeType);
        return response;
    }

}	
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;h2 id=&quot;mix-the-pagecontroller-and-normal-webapi-controllers&quot;&gt;Mix the “PageController” and normal WebAPI Controllers&lt;/h2&gt;

&lt;p&gt;In my sample the “PageController” will catch all requests that are not handled by other controllers, so you could even serve a general 404 page.&lt;/p&gt;

&lt;h2 id=&quot;hosting-in-iis&quot;&gt;Hosting in IIS&lt;/h2&gt;

&lt;p&gt;If you host this inside an IIS it will not work out of the box, because the IIS itself tries to serve static content. One easy option would be to include this inside your web.config:&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&amp;lt;!-- prevent IIS from serving embeddded stuff --&amp;gt;
&amp;lt;location path=&quot;pages&quot;&amp;gt;
    &amp;lt;system.webServer&amp;gt;
        &amp;lt;handlers&amp;gt;
            &amp;lt;add name=&quot;nostaticfile&quot; path=&quot;*&quot; verb=&quot;GET&quot; type=&quot;System.Web.Handlers.TransferRequestHandler&quot; preCondition=&quot;integratedMode,runtimeVersionv4.0&quot; /&amp;gt;
        &amp;lt;/handlers&amp;gt;
    &amp;lt;/system.webServer&amp;gt;
&amp;lt;/location&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;With this web.config setting in place the request should route through your code.&lt;/p&gt;

&lt;h2 id=&quot;result&quot;&gt;Result&lt;/h2&gt;

&lt;p&gt;The self hosting WebAPI returns the “index.html” and the linked “site.css” - all embedded inside the assembly:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://blog.codeinside.eu/assets/md-images/2015-12-31/embeddedresources-result.png&quot; alt=&quot;x&quot; title=&quot;Result of Democode&quot; /&gt;&lt;/p&gt;

&lt;p&gt;In an &lt;a href=&quot;http://blog.codeinside.eu/2015/09/29/wpf-chrome-embedded-and-webapi-selfhosting/&quot;&gt;older blogpost&lt;/a&gt; I used a similar approach, but the routing part is now “better” solved.&lt;/p&gt;

&lt;p&gt;Hope this helps!&lt;/p&gt;

&lt;p&gt;The code is also available on &lt;strong&gt;&lt;a href=&quot;https://github.com/Code-Inside/Samples/tree/master/2015/SelfHostWithBetterRoutingForEmbeddedResources&quot;&gt;GitHub&lt;/a&gt;&lt;/strong&gt;.&lt;/p&gt;
</description>
                <link>https://blog.codeinside.eu/2015/12/31/serving-embedded-resources-with-aspnet-webapi/</link>
                <guid>https://blog.codeinside.eu/2015/12/31/serving-embedded-resources-with-aspnet-webapi</guid>
                <pubDate>Thu, 31 Dec 2015 13:45:00 +0000</pubDate>
        </item>

        <item>
                <title>Working with JumpLists in WPF Apps</title>
                <description>
&lt;h2 id=&quot;jumplists&quot;&gt;JumpLists?&lt;/h2&gt;

&lt;p&gt;JumpLists were introduced with Windows 7 and if it they are implemented right are pretty handy, because it can provide common functionality.&lt;/p&gt;

&lt;p&gt;A real world example:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://blog.codeinside.eu/assets/md-images/2015-11-30/jumplistdemo.png&quot; alt=&quot;x&quot; title=&quot;JumpList Demo&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;jumplists-with-net&quot;&gt;JumpLists with .NET&lt;/h2&gt;

&lt;p&gt;In pre .NET 4.0 times there was a Windows7API Code Pack available to access the JumpLists APIs of Windows and many older blogposts reference it, but since .NET 4.0 is out the JumpList APIs are part of the &lt;a href=&quot;https://msdn.microsoft.com/en-us/library/system.windows.shell.jumpitem(v=vs.110).aspx&quot;&gt;PresentationFramework.dll&lt;/a&gt;. 
So, you don’t need any other library - at least not for the stuff that I want to show you here.&lt;/p&gt;

&lt;h2 id=&quot;jumplists--windows-vista&quot;&gt;JumpLists &amp;amp; Windows Vista&lt;/h2&gt;

&lt;p&gt;A warning for everyone that still have to support Windows Vista: .NET 4.0 is supported on Windows Vista, but the JumpLists were introduced with Windows 7.
If you are trying to create a JumpList or touch the JumpList APIs your app will crash with a NotSupportedException.&lt;/p&gt;

&lt;h2 id=&quot;creating-jumplists-via-xaml&quot;&gt;Creating JumpLists via XAML&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Small warning: If you try this on Windows Vista, your app will just crash…&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;JumpLists are registred per application and the easiest way to create a (static) JumpList is via XAML in the App.xaml:&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&amp;lt;Application x:Class=&quot;Jumplist_Sample.App&quot;
            xmlns=&quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;
            xmlns:x=&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot;
            StartupUri=&quot;MainWindow.xaml&quot;&amp;gt;
    &amp;lt;Application.Resources&amp;gt;
        
    &amp;lt;/Application.Resources&amp;gt;
    &amp;lt;JumpList.JumpList&amp;gt;
        &amp;lt;JumpList ShowRecentCategory=&quot;True&quot;
                ShowFrequentCategory=&quot;True&quot;
                
                JumpItemsRejected=&quot;JumpList_JumpItemsRejected&quot;
                JumpItemsRemovedByUser=&quot;JumpList_JumpItemsRemovedByUser&quot;&amp;gt;
            
            &amp;lt;JumpTask Title=&quot;Notepad&quot; 
                    Description=&quot;Open Notepad.&quot; 
                    ApplicationPath=&quot;C:\Windows\notepad.exe&quot;
                    IconResourcePath=&quot;C:\Windows\notepad.exe&quot;/&amp;gt;
            &amp;lt;JumpTask Title=&quot;Read Me&quot; 
                    Description=&quot;Open readme.txt in Notepad.&quot; 
                    ApplicationPath=&quot;C:\Windows\notepad.exe&quot;
                    IconResourcePath=&quot;C:\Windows\System32\imageres.dll&quot;
                    IconResourceIndex=&quot;14&quot;
                    WorkingDirectory=&quot;C:\Users\Public\Documents&quot;
                    Arguments=&quot;readme.txt&quot;/&amp;gt;
        &amp;lt;/JumpList&amp;gt;
    &amp;lt;/JumpList.JumpList&amp;gt;
&amp;lt;/Application&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;h2 id=&quot;creating-jumplists-via-code&quot;&gt;Creating JumpLists via Code&lt;/h2&gt;

&lt;p&gt;The “coding” JumpList API is a bit odd to use, but still easy to understand:&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;var jt = new JumpTask
{
    ApplicationPath = &quot;C:\\Windows\\notepad.exe&quot;,
    Arguments = &quot;readme.txt&quot;,
    Title = &quot;Recent Entry for Notepad&quot;,
    CustomCategory = &quot;Dummy&quot;
};

JumpList.AddToRecentCategory(jt);



var jt2 = new JumpTask
{
    ApplicationPath = &quot;C:\\Windows\\notepad.exe&quot;,
    Arguments = &quot;readme.txt&quot;,
    Title = &quot;Code Entry for Notepad&quot;,
    CustomCategory = &quot;Dummy&quot;
};

var currentJumplist = JumpList.GetJumpList(App.Current);
currentJumplist.JumpItems.Add(jt2);
currentJumplist.Apply();
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;The “Apply()” call is needed, otherwise the new JumpItem will not be added. As you can see, you can create new JumpList entries, add (and I think you could also remove items) from the default recent category.
Besides &lt;a href=&quot;https://msdn.microsoft.com/en-us/library/system.windows.shell.jumptask(v=vs.110).aspx&quot;&gt;JumpTasks&lt;/a&gt; there is &lt;a href=&quot;https://msdn.microsoft.com/en-us/library/system.windows.shell.jumppath(v=vs.110).aspx&quot;&gt;JumpPath&lt;/a&gt;, which just contains a link.&lt;/p&gt;

&lt;p&gt;In the XAML Part I also hooked up some events, so your application can get notified when a user pins something or removes something which you might want to handle.&lt;/p&gt;

&lt;h2 id=&quot;result&quot;&gt;Result&lt;/h2&gt;

&lt;p&gt;&lt;img src=&quot;https://blog.codeinside.eu/assets/md-images/2015-11-30/jumplistresult.png&quot; alt=&quot;x&quot; title=&quot;Result of Democode&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Oh… and of course: Windows 10 still supports JumpLists and there are rumors that even UWP apps will somehow support JumpLists.&lt;/p&gt;

&lt;p&gt;A good read was &lt;a href=&quot;http://elegantcode.com/2011/01/21/wpf-windows-7-taskbar-part-two-jump-lists/&quot;&gt;this blogpost&lt;/a&gt; (and it also contains information about other Windows 7 “Taskbar”-enhancements which are still valid for Windows 10).&lt;/p&gt;

&lt;p&gt;Hope this helps!&lt;/p&gt;

&lt;p&gt;The code is also available on &lt;strong&gt;&lt;a href=&quot;https://github.com/Code-Inside/Samples/tree/master/2015/Jumplists&quot;&gt;GitHub&lt;/a&gt;&lt;/strong&gt;.&lt;/p&gt;
</description>
                <link>https://blog.codeinside.eu/2015/11/30/working-with-jumplists-in-wpf-apps/</link>
                <guid>https://blog.codeinside.eu/2015/11/30/working-with-jumplists-in-wpf-apps</guid>
                <pubDate>Mon, 30 Nov 2015 23:30:00 +0000</pubDate>
        </item>

        <item>
                <title>XML deserialize to abstract class, interface or base class</title>
                <description>
&lt;p&gt;Let’s assume we have the following XML structure:&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;cp&quot;&gt;&amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot; ?&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;Root&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;Node&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;Label&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;Id=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Label1&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;Betreff&lt;span class=&quot;nt&quot;&gt;&amp;lt;/Label&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;TextBox&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;Id=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;TextBox1&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;MultiLines=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;3&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;/Node&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;Node&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;Label&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;Id=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Label2&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;Betreff 123132&lt;span class=&quot;nt&quot;&gt;&amp;lt;/Label&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;TextBox&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;Id=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;TextBox2&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;Button&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;Id=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Button1&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;Label=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Hello World&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;Action=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Foobar&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;/Node&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;/Root&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Under &lt;Root&gt; we have n-&lt;Node&gt;-elements and each &lt;Node&gt; element has a couple of specialized elements. The elements share a common attribute, in this case &quot;Id&quot;, so we could say that we need a &quot;Base&quot;-Element.&lt;/Node&gt;&lt;/Node&gt;&lt;/Root&gt;&lt;/p&gt;

&lt;h2 id=&quot;code-deserialize-the-elements--co&quot;&gt;Code: Deserialize the elements &amp;amp; co.&lt;/h2&gt;

&lt;p&gt;The first step: We need to deserialize the &lt;Root&gt; and it's &lt;Node&gt; children.&lt;/Node&gt;&lt;/Root&gt;&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;public class Root
{
    [XmlElement(ElementName = &quot;Node&quot;)]
    public List&amp;lt;Node&amp;gt; Nodes { get; set; }
}
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Next - and this is the &lt;strong&gt;main part of this blogpost&lt;/strong&gt; - we need to describe the &lt;Node&gt; element and that it contains a list of &quot;baseelements&quot;.&lt;/Node&gt;&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;public class Node
{
    [XmlElement(typeof(LabelElement), ElementName = &quot;Label&quot;)]
    [XmlElement(typeof(TextBoxElement), ElementName = &quot;TextBox&quot;)]
    [XmlElement(typeof(ButtonElement), ElementName = &quot;Button&quot;)]
    public List&amp;lt;BaseElement&amp;gt; Elements { get; set; }
}
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;As you can see, we need to “register” each specialized known element. The default XmlSerializer will read all XmlElement Attributes and will do the main work.&lt;/p&gt;

&lt;p&gt;The last part: The base class and the specialized classes for each element.&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;public abstract class BaseElement
{
    [XmlAttribute(AttributeName = &quot;Id&quot;)]
    public string Id { get; set; }
}

public class ButtonElement : BaseElement
{
    [XmlAttribute(AttributeName = &quot;Label&quot;)]
    public string Label { get; set; }

    [XmlAttribute(AttributeName = &quot;Action&quot;)]
    public string Action { get; set; }
}

public class LabelElement : BaseElement
{
    [XmlText]
    public string Content { get; set; }
}

public class TextBoxElement : BaseElement
{
    [XmlAttribute(AttributeName = &quot;MultiLines&quot;)]
    public int MultiLines { get; set; }
}
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;h2 id=&quot;interfaces-base-classes-etc&quot;&gt;Interfaces, base classes etc.&lt;/h2&gt;

&lt;p&gt;It doesn’t matter if you choose a interface, base class or a abstract base class. The built-in XmlSerializer is flexible, but as far as I know you will need to “register” the implementation elements on the base element. So there is no “convention” or any magic in place.&lt;/p&gt;

&lt;h2 id=&quot;using-the-code&quot;&gt;Using the code&lt;/h2&gt;

&lt;p&gt;Using the XmlSerializer is simple:&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;FileStream readFileStream = new FileStream(@&quot;test.xml&quot;, FileMode.Open, FileAccess.Read, FileShare.Read);

XmlSerializer serializer = new XmlSerializer(typeof(Root));
var test = serializer.Deserialize(readFileStream);
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;&lt;img src=&quot;https://blog.codeinside.eu/assets/md-images/2015-10-25/result.PNG&quot; alt=&quot;x&quot; title=&quot;Xml Deserializer&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;serializing&quot;&gt;Serializing&lt;/h2&gt;

&lt;p&gt;If you want to serialize objects to XML with this code the XmlSerializer should be well prepared and no code changes should be needed. It just works ;)&lt;/p&gt;

&lt;p&gt;Hope this helps!&lt;/p&gt;

&lt;p&gt;The code is also available on &lt;strong&gt;&lt;a href=&quot;https://github.com/Code-Inside/Samples/tree/master/2015/XmlBaseClassDeserializer&quot;&gt;GitHub&lt;/a&gt;&lt;/strong&gt;.&lt;/p&gt;
</description>
                <link>https://blog.codeinside.eu/2015/10/25/xml-deserialize-to-abstract-class-interface-or-base-class/</link>
                <guid>https://blog.codeinside.eu/2015/10/25/xml-deserialize-to-abstract-class-interface-or-base-class</guid>
                <pubDate>Sun, 25 Oct 2015 22:00:00 +0000</pubDate>
        </item>

        <item>
                <title>Nothing to do next weekend? Come to Leipzig and join the Developer Open Space 2015</title>
                <description>
&lt;p&gt;&lt;img src=&quot;https://blog.codeinside.eu/assets/md-images/2015-10-14/dos.png&quot; alt=&quot;x&quot; title=&quot;Developer Open Space&quot; /&gt;&lt;/p&gt;

&lt;p&gt;The Developer Open Space is not a typical developer conference: There are &lt;strong&gt;no&lt;/strong&gt; fixed speakers or topics, just many other tech lovers who wants to &lt;strong&gt;learn&lt;/strong&gt; or &lt;strong&gt;share&lt;/strong&gt; &lt;strong&gt;their&lt;/strong&gt; knowledge.&lt;/p&gt;

&lt;p&gt;The Open Space was started in 2009 and was more or less Microsoft-centric, but times are changing and the technology discussions on previous Open Spaces spread to all different kinds of technology - from fancy Web, to DevOps, Functional Programming, IoT etc.&lt;/p&gt;

&lt;p&gt;But it is not just technology: If you want to talk about Soft-Skills or want to hear how other developers do their jobs just join the Developer Open Space.
Even if you want to talk about how you craft your own beer: I bet you will find your audience ;)&lt;/p&gt;

&lt;p&gt;Sounds good, right? Just visit the &lt;strong&gt;&lt;a href=&quot;https://devopenspace.de/&quot;&gt;official website&lt;/a&gt;&lt;/strong&gt; for more information. I will be there from Saturday to Sunday :)&lt;/p&gt;

&lt;h2 id=&quot;key-facts&quot;&gt;Key Facts&lt;/h2&gt;

&lt;ul&gt;
  &lt;li&gt;No fixed agenda or speakers&lt;/li&gt;
  &lt;li&gt;If you have a topic to talk about: Just do it&lt;/li&gt;
  &lt;li&gt;You are a part of this “conference”&lt;/li&gt;
  &lt;li&gt;Location: Leipzig, Germany&lt;/li&gt;
  &lt;li&gt;Date: 16.10 - 18.10.2015&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;&lt;a href=&quot;https://devopenspace.de/&quot;&gt;Official Website&lt;/a&gt;&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
                <link>https://blog.codeinside.eu/2015/10/14/developer-open-space/</link>
                <guid>https://blog.codeinside.eu/2015/10/14/developer-open-space</guid>
                <pubDate>Wed, 14 Oct 2015 23:30:00 +0000</pubDate>
        </item>

        <item>
                <title>WPF, Chrome Embedded and WebApi Self-hosted</title>
                <description>
&lt;p&gt;Building “rich desktop clients” is not a very easy task. WPF can be a good choice for “fat” Windows Apps, but if you have zero knowledge in XAML you might end up in hell, because… XAML, right? If you are more a “web guy” (like myself) or just want to reuse existing code from your Web-App and want to stick to your .NET know-how this blogpost might come handy.&lt;/p&gt;

&lt;h2 id=&quot;cross-platfrom&quot;&gt;Cross Platfrom?&lt;/h2&gt;

&lt;p&gt;If you want to go &lt;strong&gt;real cross platform&lt;/strong&gt; and don’t have any issues with Javascript there are other options available: &lt;strong&gt;&lt;a href=&quot;http://nwjs.io/&quot;&gt;nw.js&lt;/a&gt;&lt;/strong&gt; or for more advanced use cases &lt;strong&gt;&lt;a href=&quot;http://electron.atom.io/&quot;&gt;Electron&lt;/a&gt;&lt;/strong&gt;. Both frameworks seems like a good starting point, but in a “Windows Only”-environment (well… this might be a bet on the future…) or with an existing large .NET code base not the ideal solution.&lt;/p&gt;

&lt;h2 id=&quot;the-idea&quot;&gt;The idea&lt;/h2&gt;

&lt;p&gt;So, back to .NET land and the idea is clever and kinda stupid together: We want to build a small app that embeds a browser &lt;strong&gt;and&lt;/strong&gt; a server (this is more or less the same trick from Electron &amp;amp; co.).
The host should be a WPF application, because with this we could combine interesting frameworks in one application - e.g. legacy code stuff, WPF controls, web stuff… yeah!&lt;/p&gt;

&lt;h2 id=&quot;building-blocks-the-browser&quot;&gt;Building blocks: The Browser&lt;/h2&gt;

&lt;p&gt;If you just want to display “Web-Content” you can just use the &lt;strong&gt;&lt;a href=&quot;https://msdn.microsoft.com/en-us/library/system.windows.controls.webbrowser(v=vs.110).aspx&quot;&gt;built-in WebBrowser-Control&lt;/a&gt;&lt;/strong&gt;. The most common and annoying problem is that the default rendering engine is stuck in the stone age: Internet Explorer 7. Even on Windows 10 the default rendering engine will be set to IE7.
To fix this you can use some &lt;a href=&quot;https://weblog.west-wind.com/posts/2011/May/21/Web-Browser-Control-Specifying-the-IE-Version&quot;&gt;Registry-Magic&lt;/a&gt;, but this is not very elegant.&lt;/p&gt;

&lt;p&gt;A better solution would be to take a deeper look at the &lt;a href=&quot;https://github.com/cefsharp/CefSharp&quot;&gt;Chromium Embedded Framework for .NET&lt;/a&gt;. It is the rendering engine of Chrome - which gives you a super powerful platform - and is super easy to use.
The only downside: You need to &lt;a href=&quot;https://github.com/cefsharp/CefSharp/issues/576#issuecomment-61926661&quot;&gt;compile your app for x86 or x64 - AnyCPU won’t work&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;So… let’s take a look how we can achieve our goal.&lt;/p&gt;

&lt;h2 id=&quot;building-blocks-the-server&quot;&gt;Building blocks: The Server&lt;/h2&gt;

&lt;p&gt;A good option is using the HttpListener with the ASP.NET WebApi - of course you could also use NancyFx or any other OWIN/”self-host” web framework. The hosting application will use the HttpListener from your System and will listen to a specific port. As long as you use a high port number you don’t need admin privileges.&lt;/p&gt;

&lt;p&gt;For the demo I embedded the HTML inside the application, but this could be read from a resource file or any other storage in real life.&lt;/p&gt;

&lt;p&gt;As far as I know maybe you could also do some other hosting tricks, so that the application doesn’t really needs to listen to a specific port, e.g. hosting the stuff in-memory.&lt;/p&gt;

&lt;h2 id=&quot;code-server-part&quot;&gt;Code: Server Part&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;The (important) Server Parts:&lt;/strong&gt;&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;public partial class App : Application
{
    public App()
    {
        string baseAddress = &quot;http://localhost:9000/&quot;;

        webApp = WebApp.Start&amp;lt;Startup&amp;gt;(url: baseAddress);
       
    }

    public IDisposable webApp { get; set; }

    ~App()
    {
        webApp.Dispose();
    }
}

public class Startup
{
    // This code configures Web API. The Startup class is specified as a type
    // parameter in the WebApp.Start method.
    public void Configuration(IAppBuilder appBuilder)
    {
        // Configure Web API for self-host. 
        HttpConfiguration config = new HttpConfiguration();

        DefaultConnectWebApiConfig.Register(config);

        appBuilder.UseWebApi(config);
    }
}
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;The controller code: Simple ApiController which reads a embedded HTML file.&lt;/strong&gt;&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;public class DemoController : ApiController
{
    private const string ResourcePath = &quot;SelfHostAndCef.HtmlSamples.{0}&quot;;
    public static string GetTestFileContent(string folderAndFileInProjectPath)
    {
        var asm = Assembly.GetExecutingAssembly();
        var resource = string.Format(ResourcePath, folderAndFileInProjectPath);

        using (var stream = asm.GetManifestResourceStream(resource))
        {
            if (stream != null)
            {
                var reader = new StreamReader(stream);
                return reader.ReadToEnd();
            }
        }
        return String.Empty;
    }

    public HttpResponseMessage Get()
    {
        var response = new HttpResponseMessage();
        response.Content = new StringContent(GetTestFileContent(&quot;demo.html&quot;));
        response.Content.Headers.ContentType = new MediaTypeHeaderValue(&quot;text/html&quot;);
        return response;
    }

}
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;h2 id=&quot;code-the-browser&quot;&gt;Code: The Browser&lt;/h2&gt;

&lt;p&gt;This is more or less the &lt;strong&gt;&lt;a href=&quot;https://github.com/cefsharp/CefSharp.MinimalExample/&quot;&gt;“minimal cef” sample&lt;/a&gt;&lt;/strong&gt;, but for the sample it is good enough:&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&amp;lt;Window x:Class=&quot;SelfHostAndCef.DialogWindow&quot;
        xmlns=&quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;
        xmlns:x=&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot;
        xmlns:d=&quot;http://schemas.microsoft.com/expression/blend/2008&quot;
        xmlns:mc=&quot;http://schemas.openxmlformats.org/markup-compatibility/2006&quot;
        xmlns:local=&quot;clr-namespace:SelfHostAndCef&quot;
        xmlns:wpf=&quot;clr-namespace:CefSharp.Wpf;assembly=CefSharp.Wpf&quot;
        mc:Ignorable=&quot;d&quot;
        Title=&quot;DialogWindow&quot; Height=&quot;300&quot; Width=&quot;300&quot;&amp;gt;
    &amp;lt;Grid&amp;gt;
        &amp;lt;Grid.RowDefinitions&amp;gt;
            &amp;lt;RowDefinition /&amp;gt;
            &amp;lt;RowDefinition Height=&quot;Auto&quot; /&amp;gt;
        &amp;lt;/Grid.RowDefinitions&amp;gt;
        &amp;lt;wpf:ChromiumWebBrowser x:Name=&quot;Browser&quot; Grid.Row=&quot;0&quot;
                          WebBrowser=&quot;{Binding WebBrowser, Mode=OneWayToSource}&quot;
                          Title=&quot;{Binding Title, Mode=TwoWay}&quot; /&amp;gt;
        &amp;lt;StatusBar Grid.Row=&quot;1&quot;&amp;gt;
            &amp;lt;ProgressBar HorizontalAlignment=&quot;Right&quot;
                         IsIndeterminate=&quot;{Binding WebBrowser.IsLoading}&quot;
                         Width=&quot;100&quot;
                         Height=&quot;16&quot;
                         Margin=&quot;3&quot; /&amp;gt;
            &amp;lt;Separator /&amp;gt;
            &amp;lt;!-- TODO: Could show hover link URL here --&amp;gt;
            &amp;lt;TextBlock /&amp;gt;
        &amp;lt;/StatusBar&amp;gt;
    &amp;lt;/Grid&amp;gt;
&amp;lt;/Window&amp;gt;

public partial class DialogWindow : Window
{
    public DialogWindow()
    {
        InitializeComponent();
        this.Browser.Address = &quot;http://localhost:9000/api/v1/Demo&quot;;

        var hostElement = new SampleWebViewHost();
        this.Browser.RegisterJsObject(&quot;sampleWebViewHost&quot;, hostElement);

        hostElement.SampleWebViewHostInvoked += HostElementSampleWebViewHostInvoked;
    }

    private void HostElementSampleWebViewHostInvoked(object sender, SampleWebViewHostEventArgs e)
    {
        Dispatcher.Invoke(() =&amp;gt;
        {
            this.DialogResult = true;
            this.Close();
        });
    }   
}
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;h2 id=&quot;code-the-html&quot;&gt;Code: The HTML&lt;/h2&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;cp&quot;&gt;&amp;lt;!DOCTYPE html&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;html&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;lang=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;en&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;head&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;meta&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;charset=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;UTF-8&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;meta&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;http-equiv=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;X-UA-Compatible&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;content=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;IE=edge&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;title&amp;gt;&lt;/span&gt;Example Form&lt;span class=&quot;nt&quot;&gt;&amp;lt;/title&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;script &lt;/span&gt;&lt;span class=&quot;na&quot;&gt;type=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;text/javascript&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;src=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;https://code.jquery.com/jquery-2.1.4.min.js&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;/head&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;body&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;h1&amp;gt;&lt;/span&gt;SampleForm&lt;span class=&quot;nt&quot;&gt;&amp;lt;/h1&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;form&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;label&amp;gt;&lt;/span&gt;HelloWorld:&lt;span class=&quot;nt&quot;&gt;&amp;lt;/label&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;input&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;name=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;test&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;button&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;type=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;submit&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;OK&lt;span class=&quot;nt&quot;&gt;&amp;lt;/button&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;/form&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;script&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nx&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;document&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;ready&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;nx&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;form&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;submit&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;

            &lt;span class=&quot;kd&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;result&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;JSON&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;stringify&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;form&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;serializeArray&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;());&lt;/span&gt;

            &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;sampleWebViewHost&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;!=&lt;/span&gt; &lt;span class=&quot;kc&quot;&gt;null&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
                &lt;span class=&quot;nx&quot;&gt;sampleWebViewHost&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;done&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;result&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
            &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

            &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;kc&quot;&gt;false&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
        &lt;span class=&quot;p&quot;&gt;});&lt;/span&gt;

    &lt;span class=&quot;p&quot;&gt;});&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;/body&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;/html&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;h2 id=&quot;building-blocks-browser-to-app-communication&quot;&gt;Building blocks: Browser-to-App communication&lt;/h2&gt;

&lt;p&gt;There are several ways how to interact between the hosting app and the web-app. One way is via URLs or using standard web methods. If you host the server component, then you can invoke anything inside your app.
Another solution would be to register a “scriptable” Javascript object inside the Browser-Control. I already blogged about the &lt;a href=&quot;http://blog.codeinside.eu/2013/09/04/interaktionen-zwischen-web-und-windows-desktopwindows-phonewinrt-mit-objectforscripting-window-external-notify/&quot;&gt;“window.external” api&lt;/a&gt; (in German). With this “scriptable” object in place you can call .NET functions from Javascript or the other way around.&lt;/p&gt;

&lt;h2 id=&quot;the-full-lifecycle&quot;&gt;The full lifecycle&lt;/h2&gt;

&lt;ul&gt;
  &lt;li&gt;Application starts and “self-hosts” the WebApi and listens on Port 9000&lt;/li&gt;
  &lt;li&gt;WPF Window is displayed with a large button&lt;/li&gt;
  &lt;li&gt;The Button will invoke the actual WebBrowser Control and set up a “scriptable” Javascript object&lt;/li&gt;
  &lt;li&gt;User fills in the desired data, press OK inside the WebBrowser and sends the data (in this case) to the WebBrowser-Host via the “scriptable” Javascript object&lt;/li&gt;
  &lt;li&gt;Our technology mix is complete: We can host our own WebApp inside our WinApp&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;img src=&quot;https://blog.codeinside.eu/assets/md-images/2015-09-29/demo.gif&quot; alt=&quot;x&quot; title=&quot;Demo&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;tldr&quot;&gt;TL;DR&lt;/h2&gt;

&lt;p&gt;Ok… as I told you this blogpost shows you a really stupid or really clever trick (it depends on your habbits… WebGuy vs. WindowsGuy).
In this example we used a self-hosting WebApi to display an embedded HTML page via CEF Sharp inside a Windows App.&lt;/p&gt;

&lt;p&gt;It’s magic, right?&lt;/p&gt;

&lt;p&gt;The full code can be found on &lt;strong&gt;&lt;a href=&quot;https://github.com/Code-Inside/Samples/tree/master/2015/SelfHostAndCef&quot;&gt;GitHub&lt;/a&gt;&lt;/strong&gt;.&lt;/p&gt;
</description>
                <link>https://blog.codeinside.eu/2015/09/29/wpf-chrome-embedded-and-webapi-selfhosting/</link>
                <guid>https://blog.codeinside.eu/2015/09/29/wpf-chrome-embedded-and-webapi-selfhosting</guid>
                <pubDate>Tue, 29 Sep 2015 23:30:00 +0000</pubDate>
        </item>

        <item>
                <title>FAKE: Running MSTest Tests with FAKE without knowing a tiny bit of F#</title>
                <description>
&lt;p&gt;&lt;em&gt;This is a follow-up to my xUnit FAKE post &lt;a href=&quot;http://blog.codeinside.eu/2015/02/24/fake-running-xunit-tests-with-fake/&quot;&gt;“FAKE: Running xUnit Tests with FAKE without knowing a tiny bit of F#”&lt;/a&gt;&lt;/em&gt;.&lt;/p&gt;

&lt;h2 id=&quot;running-mstests-with-fake&quot;&gt;Running MSTests with FAKE&lt;/h2&gt;

&lt;p&gt;Running MSTests is not a big difference to run xUnit tests. The biggest difference: You don’t need to pull a test runner via NuGet, because the typical Visual Studio installation will ship with the MSTest runner.&lt;/p&gt;

&lt;h2 id=&quot;mstest-test-project&quot;&gt;MSTest Test Project&lt;/h2&gt;

&lt;p&gt;The actual test is just stupid, but should work for the demo:&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;[TestClass]
public class FoobarMsTests
{
    [TestMethod]
    public void DoAStupidTest()
    {
        Assert.IsTrue(true);
    }
}
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;h2 id=&quot;adding-the-test-to-the-buildfsx-script&quot;&gt;Adding the test to the build.fsx script&lt;/h2&gt;

&lt;p&gt;This time I will only show the important parts for the tests (skipping the targets from the &lt;a href=&quot;http://blog.codeinside.eu/2015/02/23/fake-building-with-fake/&quot;&gt;first post&lt;/a&gt;).&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;// include Fake lib
open Fake.MSTest
...

// Properties
...
let artifactsTestsDir  = &quot;./artifacts/tests/&quot;

// Targets
Target &quot;BuildTests&quot; (fun _ -&amp;gt;
trace &quot;Building Tests...&quot;
!! &quot;**/*Tests.csproj&quot;
  |&amp;gt; MSBuildDebug artifactsTestsDir &quot;Build&quot;
  |&amp;gt; Log &quot;TestBuild-Output: &quot;
)

Target &quot;RunTests&quot; (fun _ -&amp;gt;
    trace &quot;Running Tests...&quot;
    !! (artifactsTestsDir + @&quot;\*Tests.dll&quot;) 
      |&amp;gt; MSTest (fun p -&amp;gt; {p with ResultsDir = artifactsTestsDir })
)
...
// Dependencies
&quot;Clean&quot;
  ==&amp;gt; &quot;BuildApp&quot;
  ==&amp;gt; &quot;BuildTests&quot;
  ==&amp;gt; &quot;RunTests&quot;
  ==&amp;gt; &quot;Default&quot;

// start build
RunTargetOrDefault &quot;Default&quot;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;The properties are more or less the same as in the xUnit sample. We still use the “artifacts”-property, which points to the build output of the test project:&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;let artifactsTestsDir  = &quot;./artifacts/tests/&quot;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;This path is used in the &lt;strong&gt;build&lt;/strong&gt; target. With this call I build all projects that ends with &lt;em&gt;Tests.csproj&lt;/em&gt;.&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;Target &quot;BuildTests&quot; (fun _ -&amp;gt;
trace &quot;Building Tests...&quot;
!! &quot;**/*Tests.csproj&quot;
  |&amp;gt; MSBuildDebug artifactsTestsDir &quot;Build&quot;
  |&amp;gt; Log &quot;TestBuild-Output: &quot;
)
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Now we need to invoke the test runner. FAKE already have a &lt;a href=&quot;http://fsharp.github.io/FAKE/apidocs/fake-mstest.html&quot;&gt;MSTestHelper&lt;/a&gt;, so this is really trivial. MSTest can be invoked with a parameter called “ResultsDir”, where we store the results. In the xUnit-world this property was called “OutputDir”.&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;Target &quot;RunTests&quot; (fun _ -&amp;gt;
    trace &quot;Running Tests...&quot;
    !! (artifactsTestsDir + @&quot;\*Tests.dll&quot;) 
      |&amp;gt; MSTest (fun p -&amp;gt; {p with ResultsDir = artifactsTestsDir })
)
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Pointed to the test directory and FAKE will do all the hard work.&lt;/p&gt;

&lt;p&gt;As you can see, running MSTests is not that different from running xUnit tests.&lt;/p&gt;

&lt;p&gt;You can find the complete &lt;a href=&quot;https://github.com/Code-Inside/Samples/tree/master/2015/LetsUseFake-MSTest/LetsUseFake&quot;&gt;sample &amp;amp; build script on GitHub&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;BTW:
To be clear, I prefer xUnit over MSTest, but in some enterprise projects or with an existing environment MSTest could be a simpler entry point to unit testing.&lt;/p&gt;
</description>
                <link>https://blog.codeinside.eu/2015/08/30/fake-running-mstest-tests-with-fake/</link>
                <guid>https://blog.codeinside.eu/2015/08/30/fake-running-mstest-tests-with-fake</guid>
                <pubDate>Sun, 30 Aug 2015 23:30:00 +0000</pubDate>
        </item>

        <item>
                <title>Reg.exe or how to import .reg files without admin privileges</title>
                <description>
&lt;p&gt;The beloved Registry is still an important part of Windows, because of COM, protocol mappings, program registrations etc. - so, even in 2015 we might have to deal with it.&lt;/p&gt;

&lt;h2 id=&quot;problem-writing-some-registry-keys-without-admin-privileges&quot;&gt;Problem: Writing some Registry keys without admin privileges&lt;/h2&gt;

&lt;p&gt;Everytime I need to fiddle around in the Registry I use “RegEdit”, but “RegEdit” needs admin privileges - because it can change everything (as far as I know).
The fun part is: Not all hives (the trees inside the registry-tree-structure) needs admin permissions. A typical user has the following permissions:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Read on HKEY_CLASSES_ROOT (which is just a combinded view over the classes of HKEY_CURRENT_USER and HKEY_LOCAL_MACHINE)&lt;/li&gt;
  &lt;li&gt;Read &lt;strong&gt;and write&lt;/strong&gt; on HKEY_CURRENT_USER&lt;/li&gt;
  &lt;li&gt;Read on HKEY_LOCAL_MACHINE&lt;/li&gt;
  &lt;li&gt;Read on HKEY_USERS&lt;/li&gt;
  &lt;li&gt;Read on HKEY_CURRENT_CONFIG&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So, if I want to write a key under the HKEY_CURRENT_USER with a normal user account it should be possible, but how?&lt;/p&gt;

&lt;h2 id=&quot;solution-1-via-code&quot;&gt;Solution 1: Via Code&lt;/h2&gt;

&lt;p&gt;Code something via the &lt;a href=&quot;https://msdn.microsoft.com/en-us/library/microsoft.win32.registry(v=vs.110).aspx&quot;&gt;Registry-APIs&lt;/a&gt; in .NET (or any other language…) and it should work, without messing around with admin stuff or turning off the UAC, which is a really stupid idea.&lt;/p&gt;

&lt;h2 id=&quot;solution-2-via-regexe&quot;&gt;Solution 2: Via reg.exe&lt;/h2&gt;

&lt;p&gt;Create a .reg file and try &lt;strong&gt;reg.exe&lt;/strong&gt;. Syntax like:&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;reg.exe import myregfile.reg
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;I discovered reg.exe and found it really handy, because it is very flexible and a .reg file can easily be written without much coding.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href=&quot;https://technet.microsoft.com/en-us/library/cc732643.aspx&quot;&gt;Reg.exe&lt;/a&gt;&lt;/strong&gt; is shipped with Windows since… mh… like forever and should be safe to use.&lt;/p&gt;

&lt;h2 id=&quot;solution-3-combine-the-two-other-solutions&quot;&gt;Solution 3: Combine the two other solutions&lt;/h2&gt;

&lt;p&gt;Of course you could invoke reg.exe also via code. This way you can still use any .reg file, but “embed” it inside your application.&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;string path = &quot;\&quot;&quot; + filepath + &quot;\&quot;&quot;; 
using (var process = new Process())
{
    try 
    { 
        process.StartInfo.FileName = &quot;reg.exe&quot;; 
        process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden; 
        process.StartInfo.CreateNoWindow = true; 
        process.StartInfo.UseShellExecute = false; 
        string command = &quot;import &quot; + path; 
        process.StartInfo.Arguments = command; 
        process.Start(); 
        process.WaitForExit(); 
    }   
    catch (System.Exception) 
    { 
        // log...?
    }
}    
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Hope this helps!&lt;/p&gt;
</description>
                <link>https://blog.codeinside.eu/2015/08/11/reg-exe-or-how-to-import-reg-files-without-admin-privileges/</link>
                <guid>https://blog.codeinside.eu/2015/08/11/reg-exe-or-how-to-import-reg-files-without-admin-privileges</guid>
                <pubDate>Tue, 11 Aug 2015 23:30:00 +0000</pubDate>
        </item>

        <item>
                <title>HowTo: Write to Azure Blob Storage</title>
                <description>
&lt;p&gt;Sometimes I just want to write blogposts to memorize it better even if the stuff is actually quiet old. So… and now I present you:&lt;/p&gt;

&lt;h2 id=&quot;how-to-write-a-simple-text-to-azure-storage&quot;&gt;How To write a simple text to Azure Storage&lt;/h2&gt;

&lt;p&gt;All you need is the &lt;strong&gt;&lt;a href=&quot;https://www.nuget.org/packages/WindowsAzure.Storage/&quot;&gt;Microsoft.WindowsAzure.Storage&lt;/a&gt;&lt;/strong&gt; NuGet Package (well… there is also a &lt;a href=&quot;https://msdn.microsoft.com/en-us/library/azure/dd179355.aspx&quot;&gt;REST API available&lt;/a&gt;, but in the .NET land, this is much easier).&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;CloudStorageAccount storageAccount = CloudStorageAccount.Parse(ConfigurationManager.ConnectionStrings[&quot;storage&quot;].ConnectionString);

// Create the blob client.
CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();

// Retrieve a reference to a container.
CloudBlobContainer container = blobClient.GetContainerReference(&quot;mycontainer&quot;);

// Create the container if it doesn't already exist.
container.CreateIfNotExists();

// Make it public - because sharing is good, right?
container.SetPermissions(
    new BlobContainerPermissions
    {
        PublicAccess =
    BlobContainerPublicAccessType.Blob
});

CloudBlockBlob blockBlob = container.GetBlockBlobReference(&quot;myblob&quot;);

var foobar = &quot;helloworld&quot;;

blockBlob.UploadText(foobar);
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Besides “UploadText” there a bunch of other methods available to save a stream or bytes etc..&lt;/p&gt;

&lt;p&gt;The “CloudStorageAccount.Parse” needs a well formed &lt;a href=&quot;https://www.connectionstrings.com/windows-azure/&quot;&gt;WindowsAzure Storage ConnectionString&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;That’s all. If you want to learn more: &lt;a href=&quot;https://azure.microsoft.com/en-us/documentation/articles/storage-dotnet-how-to-use-blobs/&quot;&gt;Azure Documentation&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Hope this helps!&lt;/p&gt;
</description>
                <link>https://blog.codeinside.eu/2015/08/06/howto-write-to-azure-blob-storage/</link>
                <guid>https://blog.codeinside.eu/2015/08/06/howto-write-to-azure-blob-storage</guid>
                <pubDate>Thu, 06 Aug 2015 21:15:00 +0000</pubDate>
        </item>

        <item>
                <title>Semantic Versioning in a nutshell</title>
                <description>
&lt;p&gt;I made a short tweet today and it seems I hit a nerve:&lt;/p&gt;

&lt;blockquote class=&quot;twitter-tweet&quot; lang=&quot;de&quot;&gt;&lt;p lang=&quot;en&quot; dir=&quot;ltr&quot;&gt;Instead of Major.Minor.Patch say Breaking.Feature.Bugfix - that&amp;#39;s &lt;a href=&quot;https://twitter.com/hashtag/SemVer?src=hash&quot;&gt;#SemVer&lt;/a&gt; in a nutshell.&lt;/p&gt;&amp;mdash; Robert Muehsig (@robert0muehsig) &lt;a href=&quot;https://twitter.com/robert0muehsig/status/623397900274561024&quot;&gt;21. Juli 2015&lt;/a&gt;&lt;/blockquote&gt;
&lt;script async=&quot;&quot; src=&quot;//platform.twitter.com/widgets.js&quot; charset=&quot;utf-8&quot;&gt;&lt;/script&gt;

&lt;p&gt;Because I like blogging I decided to write a small blogpost about SemVer.&lt;/p&gt;

&lt;h2 id=&quot;why-semantic-versioning-semver&quot;&gt;Why Semantic Versioning (SemVer)&lt;/h2&gt;

&lt;p&gt;In our industry we use version numbers a lot. The typical naming is &lt;em&gt;MAJOR.MINOR.PATCH&lt;/em&gt;, sometimes also &lt;em&gt;MAJOR.MINOR.PATCH.BUILD&lt;/em&gt; or instead of &lt;em&gt;PATCH&lt;/em&gt; you could say &lt;em&gt;REVISION&lt;/em&gt; - it is more or less the same.&lt;/p&gt;

&lt;p&gt;But the problem is: This is not very self describing. What is &lt;em&gt;MAJOR&lt;/em&gt; or a &lt;em&gt;REVISION&lt;/em&gt;? When should I change the &lt;em&gt;MAJOR&lt;/em&gt; version and when should I increase the &lt;em&gt;MINOR&lt;/em&gt; version etc.
You see: It sounds simple, but it is really complicated.&lt;/p&gt;

&lt;h2 id=&quot;semver&quot;&gt;SemVer&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href=&quot;http://semver.org/&quot;&gt;SemVer&lt;/a&gt;&lt;/strong&gt; is a pretty simple concept to give each part a better description.&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;Given a version number MAJOR.MINOR.PATCH, increment the:&lt;/p&gt;

  &lt;ul&gt;
    &lt;li&gt;MAJOR version when you make incompatible API changes,&lt;/li&gt;
    &lt;li&gt;MINOR version when you add functionality in a backwards-compatible manner, and&lt;/li&gt;
    &lt;li&gt;PATCH version when you make backwards-compatible bug fixes.&lt;/li&gt;
    &lt;li&gt;Additional labels for pre-release and build metadata are available as extensions to the MAJOR.MINOR.PATCH format.&lt;/li&gt;
  &lt;/ul&gt;
&lt;/blockquote&gt;

&lt;p&gt;If you change your API with breaking changes: Increase the &lt;em&gt;MAJOR&lt;/em&gt; version. A new feature? Increase the &lt;em&gt;MINOR&lt;/em&gt; version. Bugfix? Simple…&lt;/p&gt;

&lt;p&gt;So in short: &lt;strong&gt;Breaking.Feature.Bugfix&lt;/strong&gt;&lt;/p&gt;

&lt;h2 id=&quot;its-a-technical-solution---dont-try-to-get-nice-marketing-version-numbers&quot;&gt;It’s a technical solution - don’t try to get nice Marketing-Version-Numbers&lt;/h2&gt;

&lt;p&gt;SemVer is a technical solution - if you want to get great Marketing-Version-Numbers this will probably fail, so maybe you should split the “commercial” and “technical” version number.&lt;/p&gt;

&lt;blockquote class=&quot;twitter-tweet&quot; lang=&quot;de&quot;&gt;&lt;p lang=&quot;en&quot; dir=&quot;ltr&quot;&gt;There should also be a separate &amp;#39;commercial&amp;#39; number so as not to interfere so V3 - 12.166.2 &lt;a href=&quot;https://t.co/Gp61dYltkf&quot;&gt;https://t.co/Gp61dYltkf&lt;/a&gt;&lt;/p&gt;&amp;mdash; Dean McDonnell (@McDonnellDean) &lt;a href=&quot;https://twitter.com/McDonnellDean/status/623422780739072000&quot;&gt;21. Juli 2015&lt;/a&gt;&lt;/blockquote&gt;
&lt;script async=&quot;&quot; src=&quot;//platform.twitter.com/widgets.js&quot; charset=&quot;utf-8&quot;&gt;&lt;/script&gt;

&lt;h2 id=&quot;learn-more&quot;&gt;Learn more&lt;/h2&gt;

&lt;p&gt;I had read the “Breaking.Feature.Bugfix” summary somewhere else (maybe from &lt;a href=&quot;https://medium.com/javascript-scene/software-versions-are-broken-3d2dc0da0783#.dcegtibf1&quot;&gt;this blogpost?&lt;/a&gt;), but I can’t remember the original author (Kudos!), but I received this Tweet with a full talk about exactly this topic, so if you want to learn more:&lt;/p&gt;

&lt;blockquote class=&quot;twitter-tweet&quot; lang=&quot;de&quot;&gt;&lt;p lang=&quot;en&quot; dir=&quot;ltr&quot;&gt;&lt;a href=&quot;https://twitter.com/robert0muehsig&quot;&gt;@robert0muehsig&lt;/a&gt; &lt;a href=&quot;https://twitter.com/PascalPrecht&quot;&gt;@PascalPrecht&lt;/a&gt; Glad you like it :) The original tweet: &lt;a href=&quot;https://t.co/QGlydUsPYg&quot;&gt;https://t.co/QGlydUsPYg&lt;/a&gt; + an entire talk: &lt;a href=&quot;https://t.co/iydJudpqYW&quot;&gt;https://t.co/iydJudpqYW&lt;/a&gt;&lt;/p&gt;&amp;mdash; Stephan Bönnemann (@boennemann) &lt;a href=&quot;https://twitter.com/boennemann/status/623451396386476032&quot;&gt;21. Juli 2015&lt;/a&gt;&lt;/blockquote&gt;
&lt;script async=&quot;&quot; src=&quot;//platform.twitter.com/widgets.js&quot; charset=&quot;utf-8&quot;&gt;&lt;/script&gt;

&lt;h2 id=&quot;well&quot;&gt;Well…&lt;/h2&gt;

&lt;p&gt;Just for fun:&lt;/p&gt;

&lt;blockquote class=&quot;twitter-tweet&quot; lang=&quot;de&quot;&gt;&lt;p lang=&quot;en&quot; dir=&quot;ltr&quot;&gt;&lt;a href=&quot;https://twitter.com/robert0muehsig&quot;&gt;@robert0muehsig&lt;/a&gt; &lt;a href=&quot;https://twitter.com/chrisoldwood&quot;&gt;@chrisoldwood&lt;/a&gt; I use node, so versioning is Unused.Breaking.Breaking ;)&lt;/p&gt;&amp;mdash; I, Dom Davis (@idomdavis) &lt;a href=&quot;https://twitter.com/idomdavis/status/623492934734872576&quot;&gt;21. Juli 2015&lt;/a&gt;&lt;/blockquote&gt;
&lt;script async=&quot;&quot; src=&quot;//platform.twitter.com/widgets.js&quot; charset=&quot;utf-8&quot;&gt;&lt;/script&gt;

&lt;p&gt;;)&lt;/p&gt;

&lt;p&gt;Hope this helps!&lt;/p&gt;
</description>
                <link>https://blog.codeinside.eu/2015/07/21/semver-in-a-nutshell/</link>
                <guid>https://blog.codeinside.eu/2015/07/21/semver-in-a-nutshell</guid>
                <pubDate>Tue, 21 Jul 2015 23:30:00 +0000</pubDate>
        </item>

        <item>
                <title>Using PCLs in ASP.NET</title>
                <description>
&lt;h2 id=&quot;weird-error-message&quot;&gt;Weird Error Message:&lt;/h2&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;Compilation Error

Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: CS0012: The type ‘System.Object’ is defined in an assembly that is not referenced. You must add a reference to assembly ‘System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a’.
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;h2 id=&quot;fix&quot;&gt;Fix:&lt;/h2&gt;

&lt;p&gt;Put this Assembly-Reference in the web.config:&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&amp;lt;compilation debug=&quot;true&quot; targetFramework=&quot;4.5&quot;&amp;gt;
    &amp;lt;assemblies&amp;gt;
        &amp;lt;add assembly=&quot;System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a&quot; /&amp;gt;
    &amp;lt;/assemblies&amp;gt;
&amp;lt;/compilation&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;h2 id=&quot;reason&quot;&gt;Reason:&lt;/h2&gt;

&lt;p&gt;This error occures when you are using Portable Class Libraries (PCLs) inside ASP.NET Projects. &lt;strong&gt;&lt;a href=&quot;http://www.lyalin.com/2014/04/25/the-type-system-object-is-defined-in-an-assembly-that-is-not-reference-mvc-pcl-issue/&quot;&gt;This Blogpost&lt;/a&gt;&lt;/strong&gt; provides a pretty good answer. In short: It’s an issue between runtime and build time - PCLs that are used in Razor are runtime stuff.&lt;/p&gt;

&lt;p&gt;I (re-)blogged this because I had this issue more than once ;)&lt;/p&gt;

&lt;p&gt;Hope this helps!&lt;/p&gt;
</description>
                <link>https://blog.codeinside.eu/2015/07/14/using-pcls-in-aspnet/</link>
                <guid>https://blog.codeinside.eu/2015/07/14/using-pcls-in-aspnet</guid>
                <pubDate>Tue, 14 Jul 2015 20:00:00 +0000</pubDate>
        </item>

        <item>
                <title>FAKE: Create NuGet Packages without knowing a tiny bit of F#</title>
                <description>
&lt;p&gt;&lt;em&gt;This is a follow-up to my first two FAKE posts:&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;http://blog.codeinside.eu/2015/02/23/fake-building-with-fake/&quot;&gt;“FAKE: Building C# projects without knowing a tiny bit of F#”&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://blog.codeinside.eu/2015/02/24/fake-running-xunit-tests-with-fake/&quot;&gt;“FAKE: Running xUnit Tests with FAKE without knowing a tiny bit of F#”&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;creating-nuget-packages---with-a-nuspec&quot;&gt;Creating NuGet Packages - with a NuSpec&lt;/h2&gt;

&lt;p&gt;FAKE has at least two approaches to build NuGet Packages. The first approach is that you define a NuSpec-Template and fill the missing pieces during the build via FAKE. This scenario is covered &lt;a href=&quot;http://fsharp.github.io/FAKE/create-nuget-package.html&quot;&gt;here&lt;/a&gt;.
The second on is “simpler”, at least for me (but… you know… I have no idea how to write real F# code):
You just need to manage your .nuspec manually. Currently I use this approach, because I can handle everything inside the .nuspec files and can still use FAKE for the build process.&lt;/p&gt;

&lt;h2 id=&quot;project-overview&quot;&gt;Project Overview&lt;/h2&gt;

&lt;p&gt;The sample project consists of one class library project and the .fsx file.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://blog.codeinside.eu/assets/md-images/2015-06-21/project.png&quot; alt=&quot;x&quot; title=&quot;Project Overview&quot; /&gt;&lt;/p&gt;

&lt;p&gt;The &lt;strong&gt;.nuspec&lt;/strong&gt; content:&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;cp&quot;&gt;&amp;lt;?xml version=&quot;1.0&quot;?&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;package&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;
	&lt;span class=&quot;nt&quot;&gt;&amp;lt;metadata&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;id&amp;gt;&lt;/span&gt;Test.Foobar&lt;span class=&quot;nt&quot;&gt;&amp;lt;/id&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;version&amp;gt;&lt;/span&gt;2.0.0&lt;span class=&quot;nt&quot;&gt;&amp;lt;/version&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;title&amp;gt;&lt;/span&gt;Test Foobar&lt;span class=&quot;nt&quot;&gt;&amp;lt;/title&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;authors&amp;gt;&lt;/span&gt;Code Inside Team&lt;span class=&quot;nt&quot;&gt;&amp;lt;/authors&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;owners&amp;gt;&lt;/span&gt;Code Inside Team&lt;span class=&quot;nt&quot;&gt;&amp;lt;/owners&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;licenseUrl&amp;gt;&lt;/span&gt;http://blog.codeinside.eu&lt;span class=&quot;nt&quot;&gt;&amp;lt;/licenseUrl&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;projectUrl&amp;gt;&lt;/span&gt;http://blog.codeinside.eu&lt;span class=&quot;nt&quot;&gt;&amp;lt;/projectUrl&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;requireLicenseAcceptance&amp;gt;&lt;/span&gt;false&lt;span class=&quot;nt&quot;&gt;&amp;lt;/requireLicenseAcceptance&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;description&amp;gt;&lt;/span&gt;Hello World&lt;span class=&quot;nt&quot;&gt;&amp;lt;/description&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;releaseNotes&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;/releaseNotes&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;copyright&amp;gt;&lt;/span&gt;Copyright 2015&lt;span class=&quot;nt&quot;&gt;&amp;lt;/copyright&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;tags&amp;gt;&amp;lt;/tags&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;/metadata&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;files&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;file&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;src=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;CreateNuGetViaFake.dll&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;target=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;lib\net45&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;/files&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;/package&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Important here are the required NuSpec meta fields and the files section. If you are not familiar with the &lt;a href=&quot;http://docs.nuget.org/create/nuspec-reference&quot;&gt;.nuspec syntax, take a look at the reference&lt;/a&gt;.&lt;/p&gt;

&lt;h2 id=&quot;the-fake-script&quot;&gt;The FAKE script&lt;/h2&gt;

&lt;p&gt;Now to the FAKE script. At the end of the post you will see a link to the complete script, but I will highlight the “important” parts:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Building the library&lt;/strong&gt;&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;...
let artifactsBuildDir = &quot;./artifacts/build/&quot;
...

Target &quot;BuildApp&quot; (fun _ -&amp;gt;
   trace &quot;Building App...&quot;
   !! &quot;**/*.csproj&quot;
     |&amp;gt; MSBuildRelease artifactsBuildDir &quot;Build&quot;
     |&amp;gt; Log &quot;AppBuild-Output: &quot;
)
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Nothing special - we just build the library and the output will be stored in our artifacts/build folder.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Building the NuGet package - with the correct version&lt;/strong&gt;&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;...
let artifactsNuGetDir = @&quot;./artifacts/nuget/&quot;
let artifactsBuildDir = &quot;./artifacts/build/&quot;
...

Target &quot;BuildNuGet&quot; (fun _ -&amp;gt;
   
    let doc = System.Xml.Linq.XDocument.Load(&quot;./CreateNuGetViaFake/Test.nuspec&quot;)
    let vers = doc.Descendants(XName.Get(&quot;version&quot;, doc.Root.Name.NamespaceName)) 

    NuGet (fun p -&amp;gt; 
    {p with
        Version = (Seq.head vers).Value
        OutputPath = artifactsNuGetDir
        WorkingDir = artifactsBuildDir
        })  &quot;./CreateNuGetViaFake/Test.nuspec&quot;
)
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;The built-in &lt;a href=&quot;http://fsharp.github.io/FAKE/apidocs/fake-nugethelper.html&quot;&gt;NuGetHelper&lt;/a&gt; will invoke nuget.exe with the given nuspec. We set the WorkingDir to the output of the other target and set the OutputPath to another location. The version handling is a bit complicated, because of this &lt;a href=&quot;https://github.com/fsharp/FAKE/issues/830&quot;&gt;issue&lt;/a&gt;. The default Version is 1.0.0 and FAKE will currently ignore the Version-Information inside the .nuspec.
The workaround is: Parse the .nuspec and get the version number and pass it to the NuGetHelper. Easy, right?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Make sure you include System.Xml.Linq&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;To get things running you will need to reference System.Xml.Linq like this:&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;// include Fake lib
#r &quot;packages/FAKE/tools/FakeLib.dll&quot;
#r &quot;System.Xml.Linq&quot;
open Fake
open System.Xml.Linq

RestorePackages()
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;The result: Our NuGet Package&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://blog.codeinside.eu/assets/md-images/2015-06-21/result.png&quot; alt=&quot;x&quot; title=&quot;The Result: Our NuGet Package&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;discover-the-nugethelper-or-paket-for-more-options&quot;&gt;Discover the NuGetHelper or Paket for more options&lt;/h2&gt;

&lt;p&gt;The &lt;a href=&quot;http://fsharp.github.io/FAKE/apidocs/fake-nugethelper.html&quot;&gt;NuGetHelper&lt;/a&gt; from FAKE has some pretty nice functionality built-in, for example you can publish to NuGet.org with a given access key.&lt;/p&gt;

&lt;p&gt;For a more complete solution around consuming and creating NuGet Packages take a look at &lt;a href=&quot;http://fsprojects.github.io/Paket/&quot;&gt;Paket&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;For my simple use cases FAKE was “good enough” and I hope this might help.&lt;/p&gt;

&lt;p&gt;You can find the complete &lt;a href=&quot;https://github.com/Code-Inside/Samples/tree/master/2015/CreateNuGetViaFake&quot;&gt;sample &amp;amp; build script on GitHub&lt;/a&gt;.&lt;/p&gt;
</description>
                <link>https://blog.codeinside.eu/2015/06/21/fake-create-nuget-packages/</link>
                <guid>https://blog.codeinside.eu/2015/06/21/fake-create-nuget-packages</guid>
                <pubDate>Sun, 21 Jun 2015 23:59:00 +0000</pubDate>
        </item>


</channel>
</rss>