简体   繁体   English

使用nuget更新程序包管理器控制台之外的项目文件

[英]Using nuget to update project files outside of Package Manager Console

Nuget.exe only supports managing packages at a file system/configuration level. Nuget.exe仅支持在文件系统/配置级别管理包。 The powershell commands command the magic that update the .proj files. powershell命令用于命令更新.proj文件的魔力。

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). 话虽如此,我需要能够使用Visual Studio(自动化)之外的最新版NuGet包更新csproj文件。

Basically, how do I use Install-Package (or any of the other methods) inside of an external powershell script of my own? 基本上,我如何在我自己的外部PowerShell脚本中使用Install-Package(或任何其他方法)?

UPDATE: 更新:

I would like to ability to add project references outside of VS for the following reason. 我希望能够在VS之外添加项目引用,原因如下。

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. 我正在使用TFS Nugetter从TFS构建和发布nuget包。 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. 如果构建失败,那么您需要更新VS中的nuget引用并修复编译器错误/单元测试。

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). 我一直在看NuGet源代码,我想我找到了一种简单的方法来重用NuGet源来修改VS之外的proj文件(有点)。

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. 基本上,打开一个内存版本的visual studio,运行nuget命令,然后保存。

In a build step, after GetWorkspace, I would like to run this in-memory vs to update all nuget references to the latest version. 在构建步骤中,在GetWorkspace之后,我想在内存中运行此vs以更新所有对最新版本的nuget引用。

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. 它肯定会很慢,但我们将使用相同的代码库并拥有我们需要的所有功能。

Automating Visual Studio as you describe is certainly a possibility. 正如您所描述的那样自动化Visual Studio肯定是可能的。

Another way I looked at was using SharpDevelop to install NuGet packages outside of Visual Studio . 我看到的另一种方法是使用SharpDevelop 在Visual Studio之外安装NuGet包 The NuGet PowerShell cmdlets were modified to accept a solution and you could automate installation, including the use of PowerShell scripts in a NuGet package, from the command line. 修改了NuGet PowerShell cmdlet以接受解决方案,您可以从命令行自动执行安装,包括在NuGet包中使用PowerShell脚本。 The code has not been updated so it targets an old version of NuGet but could be updated. 代码尚未更新,因此它的目标是旧版本的NuGet,但可以更新。 Again this is similar to your solution and fairly heavyweight solution. 这又类似于您的解决方案和相当重量级的解决方案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 MVC 3文件,新项目中的程序包管理器控制台中的NuGet错误 - NuGet errors in Package Manager Console on MVC 3 File, New Project NuGet包管理器控制台无法加载PowerShell - NuGet Package Manager Console unable to load PowerShell Nuget Package Manager控制台等效于“管理”复选框 - Nuget Package Manager Console equivalent for Manage checkbox 在 NuGet 包管理器控制台中列出特定包的所有可用版本 - List all available versions of a specific package in NuGet Package Manager Console 从程序包管理器控制台添加自定义nuget源(PowerShell) - Add custom nuget feed from the Package Manager Console (PowerShell) Nuget Package Manager控制台中有关PowerShell绑定的奇怪错误 - Strange errors in Nuget Package Manager Console about PowerShell bindings 如何在NuGet软件包管理器控制台中获取IVsDebugger对象? - How do I get an IVsDebugger object in the NuGet Package Manager Console? Nuget Package Manager控制台无法执行EntityFramework PowerShell脚本 - Nuget Package Manager console unable to execute entityFramework powershell scripts 在Visual Studio Nuget包管理器控制台中中止“unclosed”powershell命令 - Aborting an “unclosed” powershell command in Visual Studio Nuget Package manager console 如何在 Visual Studio 外使用包管理器控制台 powershell - How to use Package Manager Console powershell outside visual studio
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM