Blog: Software Development

Use T4 TextTemplatingFilePreprocessor in .NET Standard or PCL libraries

April 25, 2017, Software Development

For my projects NJsonSchema and NSwag I wanted to use T4 templates to programmatically generate code generating code (TextTemplatingFilePreprocessor). Adding the .tt file with its generated C# class works, even if the files are added to a PCL (Portable Class Library) or .NET Standard 1.0 project. The problem is, that the produced code does not compile because the used PCL Profile 259 (same as .NET Standard 1.0) is missing some required classes and reflection methods. To fix the compiler errors, you have to provide the missing types and methods in your assembly. To avoid name collisions with potential client assemblies […] Read more...

Tags: , , , ,

Aurelia JS: Detect dirty checked properties during development

I am currently working on new single-page web application based on the Aurelia framework. To avoid performance problems, we want to completely avoid dirty checked properties and method calls. Bindings are dirty checked whenever the framework cannot use another mechanismn than regularly polling for changes. It is important to detect dirty checked properties as early as possible so that they can direcly be avoided and not too many depenencies have to be changed. I found a simple solution: Just intercept the dirty check subscription method and print the name of the dirty checked property name to the console. In your […] Read more...

Tags: , ,

Implement custom MSBuild tasks and distribute them via NuGet

January 31, 2017, (updated on February 2, 2017), Software Development

In this article describes how to implement MSBuild tasks with inline C# or in an external .NET assembly. After doing so, we will bundle these tasks in a NuGet package, so that they can easily be distributed and updated via NuGet and executed as part of the MSBuild compilation process. This is a powerfull technique to share and manage MSBuild tasks (e.g. build scripts, code generators, etc.) in bigger environments (enterprises, open-source libraries, common/shared tasks). Write simple task with inline C# First we implement an MSBuild task with inline C# code. For the purpose of this article, a simple “Hello […] Read more...

Tags: , , ,

Aurelia JS: Implement a dialog service which renders Bootstrap UI dialogs

December 19, 2016, Software Development

I’m currently working on an SPA (single-page application) which uses the Aurelia JavaScript client framework and Bootstrap UI CSS framework. In the application I need to show various custom dialogs. This is why I implemented a reusable dialog service class which simplifies the creation of Bootstrap based dialogs. In this article I’d like to share and explain the code of this dialog service and the required helper classes. The sample code is written in TypeScript but it can easily be converted to ES6 JavaScript. Implement the dialog service and base classes First we need to implement the dialog service – […] Read more...

Tags: , , ,

.NET Core: Missing mscorlib after installing a Portable Class Library (PCL) or .NET Standard library

October 3, 2016, (updated on October 4, 2016), Software Development

.NET Core projects can reference Portable Class Libraries if one of the .NET Standard compliant profiles is used (e.g. the profile 259). However, after installing a PCL NuGet package in a .NET Core projects, you may end up with the following compiler error: The type '???' is defined in an assembly that is not referenced. You must add a reference to assembly 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. To fix this, just install the following PCL compatibility NuGet in your project: Microsoft.NETCore.Portable.Compatibility The package provides bindings for the missing “mscorlib” so that the project can be compiled without problems. Read more...

Tags: , , ,

NSwag Tutorial: Generate an Angular TypeScript client from an existing ASP.NET Web API web assembly

October 1, 2016, (updated on July 6, 2017), 11 comments, Software Development

This tutorial shows how to generate an Angular TypeScript client with the NSwag Swagger toolchain. You can use this client in your Angular 2 SPA (single-page application) to consume the web services of an existing Web API project. The metadata for the client generator will be loaded from an existing .NET assembly which contains your Web API controller classes. The NSwag project provides many other TypeScript templates (for targeting other JS frameworks) and also a C# client generator. Introduction video: For ASP.NET Core projects, I recommend to use the middleware to generate the Swagger spec (there are some problems loading […] Read more...

Tags: , , , , ,

NSwag Tutorial: Integrate the NSwag toolchain into your ASP.NET Web API project

September 30, 2016, (updated on October 1, 2016), Software Development

This tutorial shows how to integrate NSwag (Swagger toolchain for .NET) so that you can access your Web API actions with the Swagger UI and a generated C# client library. The toolchain can be integrated into the following three types of Web API projects: Global.asax-based Web projects (full .NET Framework) OWIN-based Web projects (full .NET Framework) ASP.NET Core based projects (full .NET Framework or .NET Core) For each project, the integration is a little bit different, but this tutorial will provide links to all supported ways. Just follow the steps. 1. Create and setup a new Web API project First […] Read more...

Tags: , , , , , , ,

Script to clone all Git repositories from your VSTS collection

August 23, 2016, Software Development

In this article I show you a PowerShell script which clones and pulls all Git repositories from your Visual Studio Team Services (VSTS) collection. I use this script to retrieve the complete code base so that I can run my code analysis tools on it. 1. Create a new PowerShell script file In the directory where you want to clone all repositories, create a new CloneAllRepos.ps1 script file with the following contents: # Read configuration file Get-Content "CloneAllRepos.config" | foreach-object -begin {$h=@{}} -process { $k = [regex]::split($_,'='); if(($k[0].CompareTo("") -ne 0) -and ($k[0].StartsWith("[") -ne $True)) { $h.Add($k[0], $k[1]) } } $url […] Read more...

Tags: , ,

SystemJS module loader: Enable JavaScript debugging with Visual Studio and Internet Explorer

June 26, 2016, Software Development

In a project, we switched from the JavaScript module loader RequireJS to SystemJS. After the migration, debugging JavaScript directly from Visual Studio in Internet Explorer stopped working. The problem is that Visual Studio cannot detect the loading of script files because SystemJS uses JavaScript HTTP calls instead of injected <script> tags to load modules. But there’s an option in SystemJS to use <script> tags. The option can easily be enabled as follows: <script> System.config({ meta: { "*": { scriptLoad: true } } }); </script> After enabling this setting, JavaScript debugging should work as expected. Read more...

Tags: , , , ,

How to programmatically retrieve the deployment time of an ASP.NET web site

May 26, 2016, Software Development

In one of my web projects, I wanted to append the web site deployment time to the JavaScript URLs. This way the browser uses the cached file version until a new web site version is deployed. To do so, I looked for a way to read the deployment time of the currently running ASP.NET web site. It’s actually very simple, just read the modified date of the applications Web.config: var deploymentTime = File.GetLastWriteTime(Server.MapPath("~/Web.config")) Do you known a better way to do this? Read more...

Tags:


  Page 1 of 6 Next Page »