VS2017 Failed To Install – Setup Failed To Detect Shared Configuration

Today, I tried to install Visual Studio 2017. As with too many Microsoft products lately, after paying a significant amount of money for the product, it failed on the first usage (during installation, that is) 😦

A click on “View log” revealed the following information:

The product failed to install the listed workloads and components due to one or more package failures.
[...]
Package 'Microsoft.VisualStudio.WebDeploy.Msi,version=15.0.26208.0,chip=x64' failed to install.
[...]
    Details
        MSI: C:\ProgramData\Microsoft\VisualStudio\Packages\Microsoft.VisualStudio.WebDeploy.Msi,version=15.0.26208.0,chip=x64\webdeploy_x64.msi, Properties:  REBOOT=ReallySuppress 
        Return code: 30001
        Return code details: Setup failed to detect shared configuration.

But wait! “Shared configuration” is an IIS feature. So what’s wrong here? To check that, I opened up the IIS administration console and to my surprise, I was asked to re-enter the credentials for localhost. So apparently the administration console was not able to connect to IIS. Well if IIS was not running properly, that could possibly explain why the shared IIS configuration could not be detected. So I removed and re-added the “Internet Information Service” Windows feature (restart in between required):

After that, I retried installing VS 2017 and voila – it worked 🙂

TLDR: Reinstall the “Internet Information Service” Windows feature.

TFS: Get And Modify Included And Excluded Pending Changes in Visual Studio

In this post on Stack Overflow, I posted code that allows access to the included/excluded pending changes that the user can modify via the “Pending Changes” tab on the Visual Studio Team Explorer. Here it is again… Continue reading

ANTLR cannot generate ‘org.antlr.v4.codegen.CSharp_v4_5_1Target’ code as of version 4.1-SNAPSHOT

Today I tried to create an ANTLR 4 grammar and compile it to C#. Of course, I used Sam Harwell’s C# target for ANTLR 4. I followed all instructions, added my grammar file, compiled it and got the following error:

ANTLR cannot generate ‘org.antlr.v4.codegen.CSharp_v4_5_1Target’ code as of version 4.1-SNAPSHOT

So what’s the problem? Continue reading

Adding Solution Folders Via Visual Studio Automation

In the Visual Studio Solution Explorer, you can add solution folders to group projects or project items. These solution folders do not represent folders in the file system but are merely virtual. Adding these folders in the Solution Explorer is a trivial task, but how do you do that in code via EnvDTE? Continue reading

Add A Namespace Import Via Visual Studio Automation

Suppose you had a code document represented by a FileCodeModel object. And suppose you were modifying the containing DOM. Sometimes, you might need to add a namespace import to the document (i.e. “using …” in C# of “Import …” in VB). A namespace import is represented by the CodeImport interface. Reading out the namespace imports is easy:

var imports = fileCodeModel.CodeElements.OfType<CodeImport>();

But how do you add a new CodeImport element? Well, TIL that it’s worthwhile to look at all versions of an automation interface (e.g. FileCodeModel2 instead of just FileCodeModel). Sometimes, you might find just the method you were looking for 🙂 So the answer to the question in this case is:

var fileCodeModel = (FileCodeModel2)projectItem.FileCodeModel;
fileCodeModel.AddImport("My.New.Namespace");

Automatically Loading VSIX Packages

So you’re creating a VSIX package that does not have a menu items, tool windows or command? But still you want the package to get loaded (i.e. executed) by the IDE? What a crazy thing to wish for, one might think after spending hours searching the internet on how to do that. But don’t abandon hope, yet, since the answer is nigh. Continue reading

Use T4 Templates For XSLT Transformation

Suppose you have XSLT style sheets that produce some code from XML files. Now suppose you want to integrate these style sheets into your Visual Studio solution to generate code artefacts. You could call command line tools from the pre-build event to process the XSLT files. Alternatively, you could somehow bring the XSLT markup into a T4 template and let the regular Visual Studio integration initiate execution of the template. That is actually not that difficult, but there is one major obstacle. Continue reading