support for installing code snippets

Aug 16, 2011 at 3:25 AM
Edited Aug 16, 2011 at 3:27 AM

do nuget 1.4 packages include direct support for installing code snippets or are the search hits in this forum to custom solutions to this requirement the way you handle this currently?

Aug 16, 2011 at 8:41 PM

No, nuget 1.4 don't support installing code snippets.

Aug 21, 2011 at 8:27 PM
Edited Aug 21, 2011 at 8:28 PM

thanks for configurming.  Fyi, for others trying to enable the installation and removal of code snippets as part of their package i arrived at the following working install.ps1 and uninstall.ps1 routines after reading the other discussion forum search hits on "code snippets"

install.ps1
---------------------------------------------------------------------------------------------
$vsVersions = @("9.0" "10.0", "11.0")
foreach ($vsVersion in $vsVersions)
{
    $hkcuSwMsftVsVer = "HKCU:\Software\Microsoft\VisualStudio\" + $vsVersion
    if (test-path $hkcuSwMsftVsVer)
    {
        # get-childitem $hkcuSwMsftVsVer | foreach-object { get-itemproperty $_.pspath }

        $vsRegKey = get-itemproperty $hkcuSwMsftVsVer VisualStudioLocation -erroraction silentlycontinue -errorvariable e
        if ($e) { $e[0].Exception.Message + "..no copying of code snippets will be carried out for version " + $vsVersion; break }
        $vsCodeSnippets = $vsRegKey.VisualStudioLocation + "\Code Snippets\Visual C#\My Code Snippets"
        if (test-path $vsCodeSnippets) { "copying code snippets to " + $vsCodeSnippets; copy-item $toolsPath\*.snippet -destination $vsCodeSnippets -force }
    }
}

uninstall.ps1
---------------------------------------------------------------------------------------------
$vsVersions = @("10.0", "11.0")
foreach ($vsVersion in $vsVersions)
{
    $hkcuSwMsftVsVer = "HKCU:\Software\Microsoft\VisualStudio\" + $vsVersion
    if (test-path $hkcuSwMsftVsVer)
    {
        # get-childitem $hkcuSwMsftVsVer | foreach-object { get-itemproperty $_.pspath }

        $vsRegKey = get-itemproperty $hkcuSwMsftVsVer VisualStudioLocation -erroraction silentlycontinue -errorvariable e
        if ($e) { $e[0].Exception.Message + "..no removal of code snippets will be carried out for version " + $vsVersion; break }
        $vsCodeSnippet = $vsRegKey.VisualStudioLocation + "\Code Snippets\Visual C#\My Code Snippets\WpFedIdSignIn.snippet"           
        if (test-path $vsCodeSnippets) { "removing code snippet " + $vsCodeSnippet; remove-item $vsCodeSnippet -force }
    }