Skip to main content

Posts

Showing posts with the label VS 2015

MSTest–Setting the Culture of your tests

Last week after introducing localization into our application our builds started to fail. Inside the build log we saw that only tests related to localization were failing. What happened? The problem was that the tests where expecting a specific culture to be set which was different on our local machines compared to the build server. So we needed a way to set the (UI)culture for our tests. A solution that worked for us was to set the CultureInfo.DefaultThreadCurrentCulture and CultureInfo.DefaultThreadCurrentUICulture in the Assembly initializer of our tests:   Remark: Don’t forget to add the [TestClass] attribute on top of your class otherwise MSTest will not invoke the AssemblyInitialize method.

AWS Lambda adds support for C#

Yesterday I blogged about Azure Functions and how the Visual Studio tooling can make your life easier. But the guys at Amazon are not sleeping and I noticed that they added support for C# as well. Note that the AWS Lambda functions in C# are using the .NET Core 1.0 runtime. Similar to Microsoft, you get full tooling support thanks to the AWS Toolkit for Visual Studio . Install the AWS Toolkit for Visual Studio. Open Visual Studio and create a new project. Choose the AWS Lambda Project template and click OK. Next step is to select a Blueprint. We choose the Simple S3 Function blueprint. You get a new project containing the following files aws-lambda-tools-defaults.json: . This file contains default values that the blueprint has set to help prepopulate some of the fields in the deployment wizard. Function.cs: Inside this cs file you can add your own logic. project.json: this is the default project.json for .NET core application...

Getting Type declarations in TypeScript 2.0

TypeScript has the concept of Type Definition files to provide TypeScript metadata for libraries that are not written in TypeScript. These TypeScripts files are maintained by the community and available at the DefinitelyTyped repo on GitHub. Before TypeScript 2.0 these type definition files were published on NuGet(Microsofts own package manager). As the TypeScript community kept growing and people outside the Microsoft ecosystem started using it, Microsoft decided to switch to npm as the package source for all type definitions. So starting from TypeScript 2.0 you require no tools apart from npm. Let’s try this! Open a web application in Visual Studio Right click on your project and choose Quick Install Package… from the context menu Note: if you don’t have this option, go install the Package Installer extension first The Quick Install Package window is loaded. Choose NPM from the list of package managers and specify the library for which you want to lo...

.NET Core SDK not found

I downloaded a sample project from Github to experiment with the new .NET Core.  However when I opened it, I was welcomed by the following error message: “.NET Core SDK Not Found” This is a known issue and can be solved by downloading the correct version of the .NET SDK: .NET Core 1.0.1 SDK 1.0.0-preview2-003131 download links Windows x64 - https://go.microsoft.com/fwlink/?LinkID=830694 Windows x86 - https://go.microsoft.com/fwlink/?LinkID=830695 .NET Core 1.0.0 SDK 1.0.0-preview2-003121 download links Windows x64 - https://go.microsoft.com/fwlink/?LinkID=809122 Windows x86 - https://go.microsoft.com/fwlink/?LinkID=809123 .NET Core 1.0.0 RC2 SDK 1.0.0-preview1-002702 download links Windows x64 - https://go.microsoft.com/fwlink/?LinkID=798398 Windows x86 - https://go.microsoft.com/fwlink/?LinkID=798399

Create a clean ASP.NET MVC project

One thing I find annoying when creating a new ASP.NET MVC project is that the default templates are not well suited for my needs. You can take the MVC template but then you end up with a lot of extra stuff that you don’t need or you can choose the Empty template but then it is… too empty . I need to have something in between where I have the minimal set of boilerplate code without all the extra stuff added by the MVC template. Here is a way how you can do this: Start by creating a new ASP.NET project . Choose the Empty template from the list of available templates. Click OK . Once your new (empty) project is created, right click on the project in the Solution Explorer and choose Add –> New Scaffolded Item… Choose MVC 5 Controller – Empty from the list and click on Add . After the scaffolding is complete, you have a minimal set of starter code available… Great tip from a colleague, thanks Koen!

Updating Xamarin in Visual Studio

After the announcements of the new Xamarin updates, I thought time to update! And indeed when opening Visual Studio a notification appeared telling me an update was available. But after clicking on the notification I couldn’t find how to initiate the update … Turns out that this is actually not that hard: Inside Visual Studio, click on Tools –> Options Search for Xamarin in the Options menu Select Other and click on Check Now to find and install available updates.

Web.config transformations: How to update an appsetting value

Web projects in Visual studio support the concept of web.config transformations, making it easy to update your configuration depending on the build you are using. Yesterday I had a hard time to remember what the exact syntax was to update a specific appsetting. So here is a small snippet to help me remember:

Akka.NET TestKit–No tests found to run.

I’m currently working on a project where I’m using Akka.NET and the Actor model. I’m amazed by the ease-of-use and how the actor model itself makes complex problems easy to implement. Anyway, I lost some time today investigating a problem that a colleague had. After installing TestKit and writing his first actor based unit test, the Test Runner explorer refused to work and the only output we got was: No tests found to run. After a few minutes I realized our mistake, we downloaded the Akka.TestKit.NUnit which is suitable for NUnit 2 and older. However we are using NUnit3, which requires a different NuGet package; Akka.TestKit.NUnit3 .  After installing the correct NuGet package, our tests appeared and the problem was gone. Kind of stupid to stumble over this problem because I had the same issue before (and even mentioned it explicitly in a previous blog post about Akka.NET; http://bartwullems.blogspot.be/2016/07/testing-your-akkanet-actors-using.html )

Visual Studio: Improve your build output with the BuildVision extension

This week I started a new Azure project together with 2 colleagues. While debugging an issue with Azure Service Fabric, I noticed that his build output looked completely different. He was using the BuildVision Visual Studio extension . From the website: BuildVision activates when Visual Studio starts the process of building, rebuilding or cleaning projects (solution). BuildVision tool window and Visual Studio Status Bar displays the current state of the process, for example: "Build solution 'MyApplication' started at 18:24:12 ..." or "Clean project 'MyProject' completed successfully at 18:25:20". During the process, for each project the following columns are updated: State, Build Start Time, Build End Time, Elapsed Time, etc., as well as Errors, Warnings and Messages produced by MSBuild. Indicators Panel, which is located above the table of projects, displays total number of errors, warnings and messages produced by MSBuild, the nu...

Using work item templates in TFS 2015 and VSTS

Last week I heared a colleague that he had to customize the TFS work item templates to prepopulate some fields with default values. I had some good news for him. TFS (and VSTS) has a nice productivity feature; work item templates. With work item templates you can quickly create work items which have pre-populated values for your team's commonly used fields. And that’s exactly what he needed. Here are the steps required to create a work item template: Open the TFS web portal Go to the Work hub and click on the Queries tab Click on New and choose the Work Item type you want to create a template for On the New Work Item form fill in the default values you want the template to contain. Next, If you are using VSTS choose the Copy template URL option from the context menu: If you are using TFS on premise, click on the Copy template URL button: An URL is generated and copied to your clipboard. Here is an example of the...

NUnit 3: Trace.WriteLine not captured in Test Explorer

After upgrading to NUnit 3, I noticed that no Tracing information was captured and written to the Test Output. (Note: I didn’t verify but I’m quiet sure it worked when using NUnit 2.x) After searching through the documentation and Issues list on GitHub , I found the following quote: “Currently, the "channels" we capture are Console.Out, Console.Error and TestContext.Out. ” So indeed no Trace.Write(Line) in the list. Let’s check if this statement is correct… Here is my test code: And let’s now have a look at the test results: Trace.WriteLine – no output available : TestContext.WriteLine – with output :

Validating message templates using SerilogAnalyzer

A few years ago , I switched my logging framework of choice to Serilog , a structured logging framework. To use structured logging, you use a concept called ‘message templates’. The are a simple DSL extending .NET form strings. It looks a little bit like string interpolation, but with more power. A quick example copied from the Serilog website: The stored message will be a combination of the message template with the placeholders and the properties captured in JSON format: The only problem is that similar to string.format and  in contrast to string interpolation, the compiler doesn’t give any warnings when the provided message template is incorrect or any of the parameters is missing. Time to introduce SerilogAnalyzer , a Roslyn-based analysis for code using the Serilog logging library. It checks for common mistakes and usages problems. A must have if you are using Serilog today! Download the Visual Studio Extension here: https://github.com/Suchiman/SerilogAnalyzer/r...

Visual Studio 2015 NuGet error–Exception ‘System.AggregateException’ thrown when trying to add source.

After upgrading to the latest NuGet version inside Visual Studio 2015, I couldn’t install any NuGet package anymore. Instead I got the following error message: Exception ‘System.AggregateException’ thrown when trying to add source ‘http://development/nuget/Default’. Please verify all your online package sources are available. The issue is that one of my package sources is a private feed for one of my customers and is not available anywhere else. Before updating to the latest version of NuGet, this didn’t cause any issues. But not so in the latest version … I temporarily deleted the private feed, but a real solution would be welcome!

TFS Build Error: Invalid expression term '.'

A colleague passed by my desk yesterday with the following question: We recently moved to Visual Studio 2015 and started to use some of the new C# language features in .NET 4.6, like for example Null Conditional operators . However after doing that our CI build started to fail on the Build server. What I’m doing wrong? Or are there some components missing on the build server? When I took a look at the failing build I saw the following error messages: Handlers\DocumentMestbankLoketHandler.cs (42, 0) Invalid expression term '.' Handlers\DocumentMestbankLoketHandler.cs (42, 0) Syntax error, ':' expected Handlers\DocumentMestbankLoketHandler.cs (42, 0) ; expected Handlers\DocumentMestbankLoketHandler.cs (42, 0) Invalid expression term ')' Handlers\DocumentMestbankLoketHandler.cs (42, 0) ; expected​ I started by checking the build server if .NET 4.6 and the Build tools for Visual Studio 2015 were installed. Both we...

Templates for Windows 10 Universal Apps

To speed up the creation of a Windows 10 Universal App, Intense created a set of free templates to get you started. From the site: Controls, templates, and tools for building Universal Windows Platform apps on Windows 10. The Intense toolkit consists of two parts; a library of controls and helpers distributed as NuGet package, and a Visual Studio extension with project templates for creating new UWP apps. Intense Templates Adds new project and item templates to Visual Studio 2015 for creating Universal Windows apps. The templates are available in both C# and Visual Basic flavors. Blank App Composition App Composition XAML App Content App Navigation App SplitView App You can download the required Visual Extension from the Visual Studio Gallery: https://visualstudiogallery.msdn.microsoft.com/b7076e96-d4ab-4150-b2c6-12730abd5666

Visual Studio 2015 Update 1–Parallel Test Execution

If you are still looking for an excuse to start installing Visual Studio 2015 Update 1 , here I got you one: a new feature that existed before but is now finally back in the box is Parallel Test Execution . What is it? From the release notes: The Visual Studio Test Platform introduces support parallel execution of test cases. Parallel test execution leverages the available cores on the machine, and is realized by launching the test execution engine on each available core as a distinct process, and handing it a container (assembly, DLL, or relevant artifact containing the tests to execute), worth of tests to execute. The unit of scheduling is the test container. Within each container, the tests will be executed as per the semantics of the test framework. If there are many such containers, then as processes finish executing the tests within a container, they are handed the next available container. Parallel execution is supported through all launch points - CI, command l...

NUnit Test Adapter - BadImageFormatException

Yesterday I mentioned that my NUnit tests were not discovered when I set the Build Target to ‘x64’ and that I had to change it to ‘Any CPU’ to be able to run my tests. However this only solved part of my problem as my tests started to fail with the following error message: In theses tests I’m using Noesis.Javascript, a .NET wrapper around Google’s V8 Javascript engine, that allow you to execute scripts directly from .NET code. Noesis.Javascript.dll needs the Microsoft Visual C++ Libraries and to use them, you have to set your Compiler target to a specific platform(x86 or x64). So back to start… After some research, I found a solution: Inside Visual Studio, click on Test –>Test Settings –>Default Processor Architecture This was set to X86. Changing it to X64 solved my problem.

NUnit Test Adapter–No tests found to run

Today I discovered an annoying bug in the NUnit Test Adapter , a Visual Studio extension that integrates NUnit test execution in the IDE. I created some new tests for a specific library, however when I tried to load and run my tests, nothing happened. Inside the output window I noticed the following message: What was causing the issue? When I looked at the Build settings for my test project, I saw that the Compiler platform was set to x64. After changing it to AnyCPU , my tests were discovered…

Visual Studio and Team Foundation Server 2015 ALM Virtual Machines

For years Brian Keller has been delivering a fully functional TFS VM together with a great set of hands-on-labs, everything an ALM expert needs to keep his knowledge up-to-date. Last year Brian moved away from his role as evangelist for Microsoft ALM, luckily his colleague Sachin Hridayraj continued the story. Yesterday he released a brand new Visual Studio 2015 version, complete with a revised set of hands-on-labs and demo scripts, at http://aka.ms/ALMVMs .

Visual Studio 2015–Enable NuGet Package Restore is gone

Yesterday when creating a new solution in Visual Studio 2015, I noticed that the ‘Enable NuGet Package Restore’ option had disappeared from the solution context menu. Whooops! What happened? On StackOverflow I found that Microsoft has dropped support for the 'Enable NuGet Package Restore' in VS2015. Starting from NuGet 2.7 the way NuGet Package Restore works has changed. By default the NuGet Visual Studio extension integrates into Visual Studio's build events and restores missing packages when a build begins. More information can be found in the NuGet documentation .