Moving to SDK-Style projects and package references in Visual Studio, part 2
Introduction
The SDK style projects are the new format that first appeared for .net core, but actually can be used also for nearly any type of projects in the .net world. The old style, or what we could call legacy style, is a very complex style, and it is not uncommon to be the cause of merging issues, and also can cause all sorts of weird behavior. Both styles for a C# project has the extension csproj, even if their content is so different.
How to find the best gitignore for Visual Studio and Azure DevOps
This post came about as a result of a an interesting question raised by my good friend Richard Hundhausen in Accentient. It turned out into some very interesting observations, and a few ways of handling this.
Background
When you’re starting up a new git repository for a Visual Studio project, you need a .gitignore file that matches. The gitignore file ensures that working files and folders that are not to go into source control are kept out. As Visual Studio and its extensions are growing, this list of files and folders are increasing. You need to have a gitignore file that at least matches the version of Visual Studio you’re using. Most developers notice files that they don’t think should be in source control, and exclude those (and then adds them to the gitignore file they have), but in many cases they don’t even know what that file is for, and it is inadvertently added in. Normally not causing any problem locally for that single developer, but then it may fail for the next developer down the line, or it may fail during CI builds. So it is much better to get the correct and full gitignore file when you start up your project. Less work later! And what could possibly go wrong?
Visual Studio and VSTS Git: Extend the git command line to speed up your workflow–Part 1
The most basic Git commands are built into the Visual Studio Team Explorer. The Team Explorer will cover your basic needs, but once you get beyond that, you will need to drop down to the command line. The commands are more explicit there, and you have more options, but you will soon tire of having to repeat the same basic commands again and again. Enter the Git aliases – and you can easily make your most used commands so much more short and effective.
VSIX based Test Adapters to be deprecated in Visual Studio for C# and Visual Basic to speed up testing
Test Adapters come in two flavors, VSIX based and Nuget based. The VSIX based are installed as extensions to Visual Studio and therefore will apply to all solutions you load, The Nuget based adapter packages must be installed at least into one project in your solution and will only work for that solution.
All versions of Visual Studio have supported both flavors, but from Visual Studio 2017 Update 15.8 (Preview 4) the VSIX based adapters for C# and Visual Basic will be deprecated.
A series of short recipes for VSTS, VISUAL STUDIO and NUnit
I have had a need to have more easy access to information on how to do certain stuff, and have some easy access to simple code blocks, or templates, I can copy/paste. A blog post is for me somewhat more extensive, and that format was not really suited for smaller notes. So I decided to write them down as “recipes”, which is a small post, larger than a post-it, but smaller than a full blown blog post.
Recommended extensions for Visual Studio 2017
It is time to reestablish my list of recommended VSIX extensions to Visual Studio, for 2017 and higher. The list of tools you install now with VSIX is less than before, since so many more tools are available as nuget packages, but there are still some that are very helpful. The list below show some of the ones I have found most useful. I have also added a few non-VSIX tools, but which also installs into Visual Studio.
Managing userdumps using IFIX
User dumps are powerful diagnostics you can enable when an application crashes, and in particular when you see no obvious reason for it to crash.
In my case I have been struggling with Visual Studio crashes, and have been reporting these back to Microsoft. The devs there love user dumps, because they show the exact state of the application when it crashed. A user dump can be opened in a debugger, to reveal call stacks and lot of other useful information.
How to resolve cases of Visual Studio “No tests appearing”
The Visual Studio Test Explorer can be a bit picky about showing tests. There are multiple reasons for why they don’t always show up when you expect them to do, and most of the cases are PEBKAC type of issues. That doesn’t mean it is easy, there are just becoming too many variations, and Visual Studio does not tell you what is really wrong.
The different variations of targets and adapters doesn’t make this easier. To help in diagnosing this, I have created the diagnostic flow chart shown below. Further below you will find the comments for each block and how to rectify the issues, if you don’t already know. The flowchart is mostly general, although I use NUnit as the default adapter in the examples.
Adding a terminal window to Visual Studio 2017
Visual Studio 2017 lack a proper internal terminal. The Command Line extension has been a good substitute, but it opens up in a separate window. If you work with multiple Visual Studio at the same time, you loose track of which command window belongs to which Visual Studio instance.
Visual Studio Code has it's own Terminal window built-in, so why not Visual Studio itself? Well, now it is here, a pre-pre tool called Whack Whack (named so because of how you open it).
It runs default with Powershell, and if you have installed Posh-git with your powershell, it also lights up inside WhackWhack, which is super cool! If you don’t know posh-git, it adds some cool extras to the command prompt for git, like shown above – you see the current branch and the git status straight off the command prompt and tab completes for commands and branches.
You can download the Whack Whack terminal from the Visual Studio marketplace, and the project is open sourced at Github.
How to change test naming in Visual Studio using NUnit
The Visual Studio Test Explorer user interface have been nearly the same since 2012, with only a few minor updates. One thing that have annoyed a few people are how the test names are displayed. The Test Explorer have got a bit of critique on this, but it is not that hardcoded. It can be tweaked! With NUnit3 and the NUnit3TestAdapter version 3.8 you can configure this naming yourself, which makes for some interesting possibilities.
How to control the selection of test runner in TFS/VSTS, making it work with x86/x64 selected targets
When you do test runs with the Test Explorer in Visual Studio, you can select to use either a x86 or a x64 test runner. Now, if you select to create an AnyCPU target for that component, it will not matter which one you choose, but if you select a target x86 or x64, the selected test runner has to match the selected target. Otherwise no tests will be visible in the Test Explorer.
IFIX: Create Solution Skeleton File
Download: IFix 1.7
When I start creating a new solution I normally want this in its own git repository, and I catch myself adding the same stuff over and over again. And, I often get the folder structures wrong, I seem to never get the hang of when and where Visual Studio creates a folder for the solution, why the solution ends up at the same place as the first csproj file, and I often end up moving things around to get it the way I want it.
VIsual Studio 2015–Git Amend–Commit
This post is written for those going from TFS Version Control to Git, and is an introduction to a smart improvement in Visual Studio 2015 - Commit Amend. Command Line enthusiasts already know how this is done, but it may still be useful to see how this is resolved in Visual Studio.
In TFS VC the checkin command is used to add files to version control. The command saves the file to the central TFS VC system. When using Git you operate on your own local git repository first - by committing changes to the local and then you push these changes to the external remote repository.
How to fix Visual studio loading errors, using IFix
Visual Studio is normally a very stable environment, but some times it might crash on you. This might happen if you either install some new extension, or even if you update Visual Studio. The latter can be rather annoying of course.
A “common” error message is the loading error, it says it can’t load some component correctly, like in the image below.
Visual Studio & TFS 2013 – List of extensions and tools (Part 2)
Go to Part 1 – List of Product Updates for information on Visual Studio and TFS 2013 updates
Looking for the VS 2012 product updates and extensions ? Go to Visual Studio 2012 Product and updates (Part 1) and Visual Studio 2012 extensions (Part 2)
Looking for the VS 2010 extensions ? Go to Visual Studio 2010 - List of Product Updates (Part 1) + Extensions (Part 2).
Visual Studio Build fails with MSB4086 after NuGet Update-packages command
I just got into some strange errors after I had done a NuGet update-packages of some package. The build of the solution after the update failed with a strange error on some numeric comparison which could not be done:
This one followed by an error list like this:
Visual Studio and TFS 2013 List of Product Updates (Part 1)
Looking for List of VS 2013 Extensions (Part 2)
Updated Oct 17th 2014: Visual Studio and TFS 2013 Update 4 RC
Looking for the VS 2012 product info and extensions? Go to Visual Studio 2012 Product and updates (Part 1) and Visual Studio 2012 extensions (Part 2)
Looking for the VS 2010 extensions ? Go to Visual Studio 2010 - List of Product Updates (Part 1) + Extensions (Part 2).
Looking for links to the Test Adapters.
Visual Studio & TFS 2013 – List of extensions and tools (Part 2)
Go to Part 1 – List of Product Updates for information on Visual Studio and TFS 2013 updates
Looking for the VS 2012 product updates and extensions ? Go to Visual Studio 2012 Product and updates (Part 1) and Visual Studio 2012 extensions (Part 2)
Looking for the VS 2010 extensions ? Go to Visual Studio 2010 - List of Product Updates (Part 1) + Extensions (Part 2).
Looking for links to the test adapters, go to this blog post.
Visual Studio and TFS 2013 List of Product Updates (Part 1)
This post is continued here!
Looking for List of VS 2013 Extensions (Part 2)
Updated April 12th 2014: Visual Studio 2013 Update 2 RC & TFS Server 2013 Update 2
Looking for the VS 2012 product info and extensions? Go to Visual Studio 2012 Product and updates (Part 1) and Visual Studio 2012 extensions (Part 2)
Looking for the VS 2010 extensions ? Go to Visual Studio 2010 - List of Product Updates (Part 1) + Extensions (Part 2).
How to exclude code from Code Coverage in Visual Studio unit testing using runsettings
Download: VS2012 Runsettingstemplate VS2013 Runsettingstemplate
The VS2012/13 unit test feature can generate code coverage results. It can do so for (nearly) any type of adapter you choose to use, MSTest, CPPTest (managed/native), XUnit and NUnit (but not Chutzpah (note 1)).
Assume you have a project with a set of unit tests included. For this demonstration I have used multiple different test frameworks just to show that this applies to any of these frameworks.
You choose to analyze for code coverage:
How to fix an annoying ReSharper – NuGet error
Using NuGet in Visual Studio together with ReSharper may sometimes lead you into an annoying error where ReSharper indicates your code has an error, but the solution builds just fine.
This may happen if you have a set of NuGet packages, and you either just restore them, or delete them on disk and then restore again. Your code ends up looking like this, note the red missing functions, which comes from the Moq library - which is downloaded from NuGet:
Unit testing resources and articles for Visual Studio 2012 and 2013
The last year I have written three blog posts for the Microsoft MSDN ALM blog on unit testing. The posts focused on the new test explorer with its abilities to run tests in multiple frameworks, and utilizing traits to filter what to run, both in Visual Studio and on TFS Build. I covered the adapters for NUnit, XUnit and Chutzpah.
Visual Studio and TFS 2012 List of Product Updates (Part 1)
Go to Part 2 – List of extensions and tools for Visual Studio and TFS 2012
Looking for the VS 2010 extensions ? Go to Visual Studio 2010 - List of Product Updates (Part 1) + Extensions (Part 2).
Looking for links to the test adapters, go to this blog post.
UPDATE Nov 26th 2013: Visual Studio 2012 Update 4
This information was formerly contained within my blog post on List of extensions (Part 2), but it seems better to keep this separate now, since the cadence has increased tremendously for VS 2012, and the list grows very fast.
Visual Studio & TFS 2012 – List of extensions and tools (Part 2)
Go to Part 1 – List of Product Updates for information on Visual Studio and TFS 2012 updates
Looking for the VS 2010 extensions ? Go to Visual Studio 2010 - List of Product Updates (Part 1) + Extensions (Part 2).
Looking for links to the test adapters, go to this blog post.
UPDATE Aug 18th 2013: Updates: Visual Studio Tools for Git, TypeScript, ReSharper, TFS Power Tools, Code Contracts, Build Manager, Web Essentials, Code Contracts, tangible T4 editor , Just Decompile, DotPeek ADDED: Inmeta AssociateRecentWorkItems , Unit Test Generator
Issues with mixed C++ and C# projects in Visual Studio 2012 running Code Analysis
If you have projects created under Visual Studio 2010 (SP1), and mixed C++ and C# projects in the solution, and you are using other configurations than Debug/Release x86 you may hit a very strange situation when you run the Static Code Analysis, either alone, or as part of the build.
You may get into a situation which seems like things go in circles. One error points to a place where it simply points back to the first one. This is in fact, two kind of errors causing this behavior.
Video on Architecture and Code Quality using Visual Studio 2012–interview with Marcel de Vries and Terje Sandstrom by Adam Cogan
Find the video HERE.
Updated June 28th 2012: Marcel has blogged about this too.
Adam Cogan did a great Web TV interview with Marcel de Vries and myself on the topics of architecture and code quality. It was real fun participating in this session. Although we know each other from the MVP ALM community, Marcel, Adam and I haven’t worked together before. It was very interesting to see how we agreed on so many terms, and how alike we where thinking. The basics of ensuring you have a good architecture and how you could document it is one thing. Also, the same agreement on the importance of having a high quality code base, and how we used the Visual Studio 2012 tools, and some others (NDepend for example) to measure and ensure that the code quality was where it should be. As the tools, methods and thinking popped up during the interview it was a lot of “Hey ! I do that too!”.
Fixing some Visual Studio 2012 RC install issues
Updated: June 7th 2012: Cause for the issues found! Unsupported scenario having TFS 11 Beta side-by-side. Uninstall TFS 11 Beta before or even after install of VS 2012 RC.
The Visual Studio RC has shown some install issues in some cases, particularly for those who upgrades from VS 11 Beta. These issues are caused by also having TFS 11 Beta server installed on the same machine. This is not a supported scenario. What is good is that if you forget to uninstall TFS Beta 11 first, and get these issues, all that is required is to uninstall TFS 11 Beta, and VS 2012 RC will start working correctly!
List of recommended books on TFS, Visual Studio, C# and C++ coding, Design and Development Process
UPDATED Jul 3rd 2013: Added Art of Unit Testing Version 2
UPDATED Apr 11th 2013: Added Instant TFS 2012 and Project Server 2012 Integration How-to
UPDATED Jan 12th 2013: Added Prof TFS Server 2012, TFS 2012 Starter, Pro ALM with VS 2012 and VS 2012 Cookbook
UPDATED Dec 8th 2011: Added Kanban book by David Anderson
“Send me a list of books to read” – that is what I am often asked. No more, as this list is an answer to those request!
Visual Studio Testing Tools–Two new hotfixes released
Update: These have been superseded and included in later Cumulative Updates. See http://wblo.gs/cu8v for checking what you got and updates, or download the tool. Also see info about the updates and extensions here.
During the summer Microsoft has released two important hotfixes for the Testing tools. These two hotfixes solves 7 serious problems:
# | Issue solved | Fix in : |
1.1 | Appdomain error when running a test agent on a computer with Visual Studio installed | 1) |
1.2 | Exception with search error may happen on playback of a coded UI test on some WPF controls | 1) |
1.3 | OutOfMemory exception may occur when creating a work item from the Test Result pane. More frequent when TFS server has many builds. | 1) |
1.4 | Publishing of test results and builds stop responding for tests run in a build, due to a MSTest crash. | 1) |
2.1 | Test runner says “waiting for application under test” due to a crash when running a Manual test and you create a bug or run a test. | 2) |
2.2 | Unit tests fail to start after editing of testsettings when using batch files. | 2) |
2.3 | StackOverflowException occurs in Test Manager | 2) |
Note 1: KB2544407
Tools for Metrics analysis – Visual Studio and NDepend / CppDepend – part 1
Introduction
Recently I have been involved in some projects to improve the software quality of their code base. These code bases have been rather large, and in some cases consisting of both managed code, C# and C++, and Native code in C++. The reasons for improving the code base comes from a realization of the relationship between non-optimal coding practices and runtime incidents. Runtime incidents can be anything from exceptions, out of memory conditions to functionality simply not working at all – some times with no apparent reason or messages appearing.
Code Metrics – suggestions for appropriate limits
I like Code Metrics. They give a certain "objective" evaluation of a piece of code. You can use it for yourself just to make it pinpoint potential trouble areas, or just some code where you were a bit sloppy - happens from time to time...... And when you're going to do a peer review, it's much better to point to some numbers instead of the "This code sucks....."-thing. So when it finally arrived inside Visual Studio I was delighted.
Code Metrics – suggestions for appropriate limits
I like Code Metrics. They give a certain "objective" evaluation of a piece of code. You can use it for yourself just to make it pinpoint potential trouble areas, or just some code where you were a bit sloppy - happens from time to time...... And when you're going to do a peer review, it's much better to point to some numbers instead of the "This code sucks....."-thing. So when it finally arrived inside Visual Studio I was delighted.