Category Archives: Visual Studio

VS Offline Installer Cleanup

I’ve been using the VS 2017 Offline installer for a while after reading about it here.  It works pretty well and I’ve dutifully run the layout command many times when VS has had a new update.  After a while though this folder layout grows to a significant size, especially since I also follow the layout approach on the VS preview.

After researching a bit I found the clean argument for Visual Studio setup, which can remove an older catalog.  The list of older catalogs are in the archive sub-folder of the layout folder.

So with a little experimentation, I came up with the Powershell script below.  This took my layout folder usage from 372 GB down to a mere 100 GB total for both VS and VS Preview combined.

# Cleanup.ps1
Function Clear-VSOfflineLayout

Get-ChildItem -Directory $layoutpath\Archive `
| Sort-Object CreationTime `
| ForEach-Object `
$fn = "$layoutpath\Archive\" + $_.Name + "\Catalog.json"
Write-Host $_.CreationTime.ToString() $fn
if (Test-Path $fn -PathType Leaf)
$arg = "--layout $layoutpath --clean " + $fn + " --passive"
Start-Process "$exepath" -ArgumentList $arg -Wait
Write-Host "Catalog already removed: " $fn

To run the script, pass the path of your layout folder and the path to vs_setup.exe to the powershell function

PS D:\layout>. .\cleanup.ps1
PS D:\layout> Clear-VSOfflineLayout -layoutpath "D:\Layout\Vs2017_preview_offline" -exepath "D:\layout\vs_professional_preview.exe"




In the past I used a Javascript and CSS minifier in Visual Studio that I built on top of the original YUI compressor.  I implemented it via a Custom Tool / Single File Generator.  I figured this might be helpful with minifying the output of TypeScript.  I wanted to eliminate the Java dependency however, so  I built the generator on top of YUI Compressor.NET.  Unfortunately, this doesn’t seem to work for my situation.  When TypeScript generates new Javascript output it doesn’t seem to trigger the SFG to do its thing.   In any case I put the source on Github for anyone who is interested.

Exception has been thrown by the target of an invocation

I tried creating a new, empty ASP.NET Web Application in Visual Studio 2013, with MVC support and got the exception “Exception has been thrown by the target of an invocation” repeatedly.  It always seemed to create the App_Data folder and not much else. Long story short,  after some googling,  I installed SQL Server Express 2012, made sure it was running and then started VS2013.  After that I can create the above project with no error. From this experience, I’d recommend selecting the SQL Express option when installing Visual Studio, even if you don’t plan on using a local database server.