简体   繁体   English

我的NuGet软件包在使用它作为依赖项的项目中似乎没有更新

[英]My NuGet package doesn't seem to update in projects that use it as a dependency

Forgive what must be a very simple oversight on my part but I simply cannot get this to work as expected. 原谅我必须做的非常简单的疏忽,但是我根本无法按预期进行。

I am building a .NET Framework 4.6 Class Library that needs to be downloaded by other applications from a private nuget repository. 我正在构建.NET Framework 4.6类库,其他应用程序需要从私有nuget存储库中下载该类库。 Here is my process: 这是我的过程:

  1. I have a test project, ConsoleApp5. 我有一个测试项目ConsoleApp5。 It has a simple main function in it. 它具有一个简单的主要功能。
  2. I download my NuGet package, MyPackage (right click on project and click Manage NuGet Packages, select appropriate repo and package, click install.) 我下载了我的NuGet软件包MyPackage(右键单击项目,然后单击管理NuGet软件包,选择适当的存储库和软件包,然后单击安装。)
  3. I run my test. 我进行测试。 In this case, I'm simply trying to instantiate a class, something not difficult. 在这种情况下,我只是试图实例化一个类,这并不困难。 I'm getting an error about class accessibility. 我收到有关类可访问性的错误。
  4. Back in MyPackage, I replace all instances of the word protected with public . 回到MyPackage中,我用public替换了protected的单词的所有实例。 I add a new class as well by right-clicking on the project, selecting Add Item, targeting a class and giving it the name TestClass . 我还通过右键单击项目,选择“添加项目”,定位一个类并为其命名为TestClass来添加一个新类。
  5. I go to Project > MyPackage Properties... > Application (tab) > Assembly Information, and I manually update the version patch number by one. 我转到项目> MyPackage属性...>应用程序(选项卡)>程序集信息,然后手动将版本补丁号更新一个。 So now it is 1.0.5. 所以现在是1.0.5。
  6. I go to the project directory in the Developer Command Line and run the following command: C:\\Users\\jptak\\Downloads\\nuget.exe pack -Version 1.0.5 我转到开发人员命令行中的项目目录,然后运行以下命令: C:\\Users\\jptak\\Downloads\\nuget.exe pack -Version 1.0.5
  7. Then I run the following command to push the update (Success message: Your package was pushed. ): C:\\Users\\jptak\\Downloads\\nuget.exe push MyPackage.1.0.5.nupkg MySecretCodeGoesHere -src http://my.nuget.server.goes.here.com 然后,我运行以下命令来推送更新(成功消息: Your package was pushed. ): C:\\Users\\jptak\\Downloads\\nuget.exe push MyPackage.1.0.5.nupkg MySecretCodeGoesHere -src http://my.nuget.server.goes.here.com
  8. I go back to ConsoleApp5, Manage NuGet Packages, see the update in the appropriate package, and click the update arrow. 我回到ConsoleApp5,管理NuGet程序包,在适当的程序包中查看更新,然后单击更新箭头。 The download completes and the new version number is there. 下载完成,并且有新版本号。
  9. I go to use new classes or check that old errors are fixed and all of my tests fail. 我去使用新类或检查旧错误是否已修复并且所有测试均失败。 TestClass is not there. TestClass不存在。

This leads me to believe that the code I am writing is not making it to the NuGet server. 这使我相信我正在编写的代码并未将其写入NuGet服务器。 Does anyone know what I am missing from this process to make the most recent version of the code get updated on the server? 有谁知道我在此过程中缺少什么以使最新版本的代码在服务器上得到更新?

This process is foreign to me as I am not a .NET developer (I work with PHP mostly). 由于我不是.NET开发人员(我主要使用PHP),因此此过程对我来说是陌生的。

Here are some more pieces of information about my IDE settings: 以下是有关我的IDE设置的更多信息:

  • In Build > Configuration Manager... > Debug has been switched to Release 在构建>配置管理器...中> 调试已切换到发布
  • I have tried building, rebuilding, and cleaning my project. 我尝试过构建,重建和清理项目。 I haven't seen that any of these processes has had any effect on the code being pushed at all. 我还没有看到任何这些过程对所推送的代码都没有任何影响。

Here is the code from my ConsoleApp5: 这是我的ConsoleApp5中的代码:

namespace ConsoleApp5
{
    class Program
    {
        static void Main(string[] args)
        {
            string testclient = "testclient";
            string testpass = "testpass";
            string scope = "validate-contract";
            string accessToken = "";
            string retrievedScope = "";

            MyPackage.TestClass test = new MyPackage.TestClass();
        }
    }

Error: TestClass does not exist in namespace. 错误:名称空间中不存在TestClass。 Did you forget an Assembly Reference? 您忘记了装配参考吗?

Here's the TestClass code in MyPackage: 这是MyPackage中的TestClass代码:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MyPackage
{
    public class TestClass
    {
        public TestClass()
        {

        }
    }
}

The NuGet server I'm using is: https://github.com/Daniel15/simple-nuget-server 我正在使用的NuGet服务器是: https : //github.com/Daniel15/simple-nuget-server

EDIT 1 Upon inspecting the .nupkg file, I can confirm that the old code is still there and that the new code has not made it into the .nupkg. 编辑1检查.nupkg文件后,我可以确认旧代码仍然存在,并且新代码尚未将其放入.nupkg。 This seems to support the idea that the problem is with the packaging process and not on the nuget server. 这似乎支持以下问题:打包过程而不是nuget服务器上的问题。 How does one refresh the dll files before each nuget pack / nuget push ? 如何在每次nuget pack / nuget push之前刷新dll文件?

Bit long for a comment, not exactly an answer but here we go: 有点长的评论,不完全是一个答案,但是我们开始:

So top debugging tips for NuGet packages are: 因此,NuGet软件包的主要调试技巧是:

  • Download the package manually. 手动下载软件包。 A .nupkg file is just a zip file that can be opened with 7Zip or any other archive tool. .nupkg文件只是可以使用7Zip或任何其他存档工具打开的zip文件。

  • Once inside you can inspect both the .nuspec file that has been used to pack the package, and inside the lib folder are the dlls that have been supplied. 一旦进入内部,您就可以检查用于打包程序包的.nuspec文件,以及位于lib文件夹中的已提供的dll。

  • A decompiler like DotPeek or ILSpy can be used on the dll to see exactly what is going on inside the dll. 可以在dll上使用DotPeekILSpy这样的反编译器,以查看dll内到底发生了什么。

Possible causes of your symptoms could include the NuGet server giving a false success, or your application failing to update the package and still refering to the old one. 出现症状的可能原因包括NuGet服务器显示错误的成功,或者您的应用程序无法更新程序包而仍然引用旧的程序包。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM