install.ps1 addition of project references to assemblies not in the gac

Aug 19, 2011 at 3:23 PM
Edited Aug 19, 2011 at 3:25 PM

 

I have a web projects related nuget package where my install.ps1 contains the following two entries.

$project.Object.References.Add("$env:programfiles\Windows Azure SDK\v1.4\ref\Microsoft.WindowsAzure.Diagnostics");
$project.Object.References.Add("$env:programfiles\Windows Azure SDK\v1.4\ref\Microsoft.WindowsAzure.ServiceRuntime");

q1 - when i install the package these assembly references are not getting added, am i overlooking how to accomplish adding project references to assemblies not in the gac?

q2 - from the package manager console is there a way to create the variable $project so i can debug/test things like this outside of the nuget package installation process?

q3 - similarly from a powershell console is there a way to create the variable $project so i can debug/test my .\Tools\install.ps1 routines outside of the nuget package installation process?

Coordinator
Aug 19, 2011 at 5:21 PM

a1 - If these are framework assemblies you’re adding, use the <frameworkAssemblies> node.

http://docs.nuget.org/docs/reference/nuspec-reference#Specifying_Framework_Assembly_References_(GAC)

a2 - $project = Get-Project ProjectName

a3 – From a standard PowerShell console, there is, but it’s not easy. You’d need to get a handle on the running Visual Studio instance. $project points to a DTE project which is part of the Visual Studio object model.

Aug 19, 2011 at 5:47 PM

Wrt a1 these are not framework assemblies if by that you mean .net framework assemblies.   They are assemblies installed by the current windows azure sdk and they do not show up in the <project> | references | add | .net view, you add them using <project> | references | add | browse | and then select them from the sdk path directly, e.g. "%programfiles%\Windows Azure SDK\v1.4\ref\Microsoft.WindowsAzure.Diagnostics.dll" .   That being the case any additional insights on how to get this added as a project reference based on the assumption that the target system has the azure sdk installed.  

Aug 19, 2011 at 6:03 PM
Edited Aug 19, 2011 at 6:04 PM

wrt q1 i got it to work using the following command where in addition to the program files environment variable reference fix required it also required the .dll extension in the name

$project.Object.References.Add("$env:programw6432\Windows Azure SDK\v1.4\ref\Microsoft.WindowsAzure.Diagnostics.dll");

so it seems that pm console runs from %windir%\syswow64\cmd.exe process in which case $env:programfiles=C:\Program Files (x86) and $env:programw6432=C:\Program Files

in my uninstall script i ran $project.Object.References.Remove("$env:programw6432\Windows Azure SDK\v1.4\ref\Microsoft.WindowsAzure.Diagnostics.dll");

and $project.Object.References.Remove("Microsoft.WindowsAzure.Diagnostics");

but neither worked, am i doing something wrong with this remove assembly reference syntax?

Aug 19, 2011 at 6:46 PM
Edited Aug 19, 2011 at 6:46 PM

figured out how to get uninstall non-framework or project build output assembly reference removal to work

$project.Object.References.Item("Microsoft.WindowsAzure.Diagnostics").Remove();

folks might also be interested in following as way to get install.ps1 addition of non-framework or project build assembly reference to have CopyLocal = true

$project.Object.References.Add("$env:programw6432\Windows Azure SDK\v1.4\ref\Microsoft.WindowsAzure.Diagnostics.dll");
$project.Object.References.Item("Microsoft.WindowsAzure.Diagnostics").CopyLocal = "True"

$project.Object.References.Add("$env:programw6432\Windows Azure SDK\v1.4\ref\Microsoft.WindowsAzure.ServiceRuntime.dll");

$project.Object.References.Add("$env:programw6432\Windows Azure SDK\v1.4\ref\Microsoft.WindowsAzure.StorageClient.dll");
$project.Object.References.Item("Microsoft.WindowsAzure.StorageClient").CopyLocal = "True"

Developer
Aug 19, 2011 at 6:53 PM

Fyi, that probably doesn't work in F#or website projects.

Aug 19, 2011 at 7:40 PM

i've tested the above for adding the azure sdk assembly references, and removing them in an asp.net mvc3 project and it works.   Are you referring to some other q/a above?

Developer
Aug 19, 2011 at 8:12 PM

If web application projects are all that matters then you're fine.