Adding SDKReference to csproj during package installation

Topics: General
Aug 8, 2013 at 2:28 PM
Hi All;

I have a question about adding SDKReference in a Windows Store Project during installation of my nuget package.

My nuget package dépends on two SDK installed:
  1. Microsoft Visual C++ Runtime Package
  2. SQLite (installed by VSIX installation)
I have tried many things to complete this task :
  1. Adding a target file in the build directory : Doesn't work. (Btw, i used this target file to solve the ARM/x86/x64 problem, and it works correctly)
  2. Adding an install.ps1 in tools directory : Work partially :)
The problem come from the "Refresh project" behavior :

Here is my install.ps1 powershell script :
param($installPath, $toolsPath, $package, $project)

    # Need to load MSBuild assembly if it's not loaded yet.
    Add-Type -AssemblyName 'Microsoft.Build, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'

    # Grab the loaded MSBuild project for the project
    $msbuild = [Microsoft.Build.Evaluation.ProjectCollection]::GlobalProjectCollection.LoadProject($project.FullName) | Select-Object -First 1

    # Grab the target framework version and identifier from the loaded MSBuild proect
    $targetFrameworkIdentifier = $msbuild.GetProperty("TargetFrameworkIdentifier").Xml.Value
    if ($targetFrameworkIdentifier -eq ".NETCore")
        # Add a group to store SDks    
        $group = $msbuild.Xml.AddItemGroup();
        $vcLibsProp = New-Object 'System.Collections.Generic.Dictionary[String, String]'
        $vcLibsProp.Add("Name", "Microsoft Visual C++ Runtime Package")
        $group.AddItem("SDKReference", "Microsoft.VCLibs, version=11.0", $vcLibsProp)
        $sqliteProp = New-Object 'System.Collections.Generic.Dictionary[String, String]'
        $sqliteProp.Add("Name", "SQLite for Windows Runtime")
        $group.AddItem("SDKReference", "SQLite.WinRT, Version=3.7.17", $sqliteProp)
This code works, but the references don't appears in the project. I see my own dll from my package but not the reference from VCLibs and SQLite.
By The Way, if I restart Visual Studio, my project show correctly the SDK references.

The only solution I have found to force refresh the Visual Studio References view is to add in my powershell script the line :
The problem here is the dialog box requesting "Do you want to refresh the project, because it has been modified ...."

Any suggestions ?

Thank you !

(Sorry for my poor English :) )

Aug 19, 2013 at 9:28 AM
Any help ?

Thx !

Jul 23, 2014 at 12:25 PM
Got stuck at the same issue. It's really poor that VS extension references cannot be managed via nuget (or at least package target files).