3

Nuget.exe only supports managing packages at a file system/configuration level. The powershell commands command the magic that update the .proj files.

With that said, i need the ability to update a csproj file with the latest version of a NuGet package outside of visual studio (automated).

Basically, how do I use Install-Package (or any of the other methods) inside of an external powershell script of my own?

UPDATE:

I would like to ability to add project references outside of VS for the following reason.

My company has a lot of shared libraries that depend on each other in some cases. I am using TFS Nugetter to build and publish nuget packages from TFS. I want to ensure that the developers can't queue a build (package) unless the project can build and run on all the newer versions. This ensures that all the newer versions of the libraries work with all the newer versions of its dependencies. If the build fails, then you need to update your nuget reference in VS and fix the compiler errors/unit tests.

I have been looking at the NuGet source and I think I found an easy way to reuse NuGet source to modify proj files outside of VS (kinda).

System.Type t = System.Type.GetTypeFromProgID("VisualStudio.DTE.10.0", true);
var dte = (DTE)System.Activator.CreateInstance(t, true); 
dte.Solution.Open( 
    @"C:\Users\paul.knopf\Documents\Visual Studio 2010\Projects\SLNMemory\SLNMemory.sln");

Basically, open an in-memory version of visual studio, run the nuget commands, then save.

In a build step, after GetWorkspace, I would like to run this in-memory vs to update all nuget references to the latest version.

What do you think? It would definitely be slow, but we would be on the same code base and have all the functionality we need.

4

1 回答 1

1

正如您所描述的那样自动化 Visual Studio 无疑是一种可能性。

我看到的另一种方法是使用 SharpDevelop 在Visual Studio 之外安装 NuGet 包。NuGet PowerShell cmdlet 已修改为接受解决方案,您可以从命令行自动安装,包括在 NuGet 包中使用 PowerShell 脚本。该代码尚未更新,因此它针对的是旧版本的 NuGet,但可以更新。同样,这类似于您的解决方案和相当重量级的解决方案。

于 2012-07-09T14:23:32.000 回答