的NuGet缓存和版本问题 [英] NuGet Cache And Versioning Issues

查看:319
本文介绍了的NuGet缓存和版本问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用的NuGet抢鲜包的问题,​​想知道别人在这种情况下所做的那样。的NuGet功能似乎完全不同的,坦率地说,奇怪,从Maven的预期行为。对于一个简单的例子,假设我们有集会FooAssembly和BarAssembly,以定义的类如下:



富:



<前类=郎-CS prettyprint-覆盖> 命名空间的Foo {
类FooClass {
公共无效特斯塔(){
}
}
}

酒吧:



<预类= 郎咸平-CS prettyprint-覆盖> 命名空间酒吧{
类BarClass {
公共静态无效的主要(字串[] args){
FooClass富=新FooClass( );
foo.TestA();
}
}
}

当我建富,这是版本这样就产生富-1.0.0-SNAPSHOT.nupkg。的NuGet安装此进入酒吧时,我将其添加作为一个依赖,将其放置在我的两个本地缓存在%APPDATA%和包在我的源代码树文件夹中。现在,如果我添加方法TESTB()来富,并重建,它也产生美孚-1.0.0-SNAPSHOT.nupkg。我生成如预期这个新nupkg文件放入我的%APPDATA%缓存。然而,当我尝试做一个重建酒吧,的NuGet不检测我的%APPDATA%nupkg已经改变,因此没有可用的新方法TESTB。我必须手动删除的src /包文件夹(或至少是包美孚子目录),才能重新获取来自我的缓存包。



在Maven的,如果我为重建与富加TESTB方法,它将使富-1.0.0-SNAPSHOT在我的.m2目录缓存,以及酒吧将连接对罐子的新版本,并会了解TESTB。



我的问题是,首先,我失去了与的NuGet的东西吗?其次,如果我不是,人们已经做了什么来解决这个缺点?添加一个MSBuild预构建的步骤全歼该项目包缓存?追加版本号以快照的结尾(例如:SNAPSHOT42 ...这似乎是将它与对项目不止一个开发商有问题)?



任何有识之士表示赞赏。谢谢你。


解决方案

没有的NuGet行家快照的等效



的NuGet没有按'T真正支持快照依赖类似Maven呢,虽然有一个悬而未决的问题来实现类似的东西,一个讨论了解这样的功能。



一个Possibilitie建议是写一个脚本:




  • 生成一个新的Foo包有不同的版本

  • 更新吧引用最新版本的foo



另一种替代方法



另外,当我在我自己的项目工作,我总是建立和参考从源代码。然后,一旦项目变得不够稳定,我不更新它太大了,我再开始停止引用通过源代码,而是建立并引用作为的NuGet包。


I'm having issues with NuGet prerelease packages and was wondering what others had done in this situation. NuGet functionality seems completely different, and frankly, strange, from expected behavior in Maven. For a quick example, let's say we have assemblies FooAssembly and BarAssembly, with classes defined as follows:

Foo:

namespace Foo {
    class FooClass {
         public void TestA(){
         }
    }
}

Bar:

namespace Bar {
    class BarClass {
         public static void Main(string[] args){
             FooClass foo = new FooClass();
             foo.TestA();
         }
    }
}

When I build Foo, it's versioned such that it generates Foo-1.0.0-SNAPSHOT.nupkg. NuGet installs this into Bar when I add it as a dependency, placing it in both my local cache under %APPDATA% and a packages folder in my source tree. Now, if I add method TestB() to Foo, and rebuild, it also generates Foo-1.0.0-SNAPSHOT.nupkg. My build places this new nupkg file into my %APPDATA% cache as expected. However, when I try to do a rebuild of Bar, NuGet doesn't detect that my nupkg in %APPDATA% has changed, and therefore doesn't have the new TestB method available. I have to manually delete the src/packages folder (or at least the Foo subdirectory in packages) for it to reacquire the package from my cache.

In Maven, if I were to rebuild Foo with the TestB method added, it would place Foo-1.0.0-SNAPSHOT in my .m2 cache, and Bar would link against the new version of the jar and would know about TestB.

My question is, firstly, am I missing something with NuGet? Secondly, if I'm not, what have people done to work around this shortcoming? Add an MSBuild pre-build step to wipe out the project package cache? Append build numbers to the end of SNAPSHOT (e.g. SNAPSHOT42...this seems like it would be problematic with more than one developer on the project)?

Any insight is appreciated. Thanks.

解决方案

No Nuget Equivalent of maven SNAPSHOTs

NuGet doesn't really support SNAPSHOT dependencies like Maven does, although there is an open issue to implement something similar and a discussion about such functionality.

A Possibilitie suggested was to write a script to:

  • Generate a new Foo package with a different version
  • Update Bar to reference the latest version of Foo

An Alternative Approach

Alternatively when I work on my own projects, I always build and reference Foo from source. Then, once Foo project becomes stable enough that I don't update it much anymore, I then start stop referencing Foo via source and instead build it and reference as a nuget package.

这篇关于的NuGet缓存和版本问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆