Created
September 16, 2014 16:03
-
-
Save mhinze/e65789ed26107038072c to your computer and use it in GitHub Desktop.
Solution Script for disabling nservicebus check when loading sln in visual studio
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function global:Disable-NServiceBusSetupCheck() | |
{ | |
#default to current dir when debugging | |
if(!$solutionScriptsContainer){ | |
$solutionScriptsContainer = "./" | |
} | |
$packagesFolder = Join-Path $solutionScriptsContainer "..\packages" -Resolve | |
Push-Location $packagesFolder | |
# Load NSB powershell module | |
$nsbPowerShellPath = Get-ChildItem . -Recurse -Filter NServiceBus.PowerShell.dll | Select-Object -First 1 | |
if (Get-Module NServiceBus.Powershell) { | |
Remove-Module NServiceBus.Powershell | |
} | |
Import-Module ($nsbPowerShellPath.FullName) | |
# Setup registry variables | |
$nserviceBusKeyPath = "HKCU:SOFTWARE\NServiceBus" | |
$machinePreparedKey = "MachinePrepared" | |
$dontCheckMachineSetupKey = "DontCheckMachineSetup" | |
$machinePrepared = $false | |
$nservicebusVersion = Get-NServiceBusVersion | |
$nserviceBusVersionPath = $nserviceBusKeyPath + "\" + $nservicebusVersion.Major + "." + $nservicebusVersion.Minor | |
# If NSB registry entries are missing for the current version, then create them. There is an issue in the current script where this is broken. | |
if (!(Test-Path $nserviceBusKeyPath)) { | |
New-Item -Path HKCU:SOFTWARE -Name NServiceBus | Out-Null | |
} | |
if (!(Test-Path $nserviceBusVersionPath)){ | |
$versionToAdd = "$($nservicebusVersion.Major).$($nservicebusVersion.Minor)" | |
New-Item -Path $nserviceBusKeyPath -Name $versionToAdd | Out-Null | |
New-ItemProperty -Path $nserviceBusVersionPath -Name $machinePreparedKey -PropertyType String -Value "false" | Out-Null | |
New-ItemProperty -Path $nserviceBusVersionPath -Name $dontCheckMachineSetupKey -PropertyType String -Value "true" | Out-Null | |
} | |
else { | |
# If NSB registry entries are present, ensure setup check is disabled. | |
$a = Get-ItemProperty -path $nserviceBusVersionPath | |
$dontCheckMachineSetup = $a.psobject.properties | ?{ $_.Name -eq $dontCheckMachineSetupKey } | |
# Only set the registry entry if it is not already there. This allows users to still turn the check on if they choose. | |
if(!$dontCheckMachineSetup) { | |
New-ItemProperty -Path $nserviceBusVersionPath -Name $dontCheckMachineSetupKey -PropertyType String -Value "true" | Out-Null | |
} | |
} | |
Pop-Location | |
} | |
Disable-NServiceBusSetupCheck |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment