[英]How can I revert to referencing Nuget packages in packages.config after using Package References in a .NET Standard project?
I have several C# code libraries which I recently converted to target .NET Standard 1.4, for use in a Xamarin Forms project as well as many legacy .NET Framework 4.6.1 projects. 我有几个C#代码库,我最近转换为目标.NET Standard 1.4,用于Xamarin Forms项目以及许多遗留的.NET Framework 4.6.1项目。
I initially added Nuget packages to the .NET Standard class libraries using the Package Reference in Project Files style. 我最初使用Project Files样式中的Package Reference将Nuget包添加到.NET Standard类库中 。
After learning of this bug where transitive package references from .NET Standard projects are not resolved in legacy .NET Framework projects , I tried the workaround of adding <RestoreProjectStyle>PackageReference</RestoreProjectStyle>
to the legacy project's csproj. 在了解了传统.NET Framework项目中未解析.NET Standard项目中的传递包引用的此错误之后,我尝试了将<RestoreProjectStyle>PackageReference</RestoreProjectStyle>
到旧项目的csproj中的解决方法。 The legacy projects continued to not resolve the transitive references- that is, the workaround didn't work. 遗留项目仍然没有解决传递性引用 - 也就是说,解决方法不起作用。
So, I would like to revert to the old style of referencing Nuget packages in a packages.config file in my .NET Standard project. 所以,我想恢复我的.NET Standard项目中的packages.config文件中引用Nuget包的旧样式。
Manage Nuget Packages
tool window 从Manage Nuget Packages
工具窗口重新安装Nuget包
PackageReference
, not in a packages.config file. 此包作为PackageReference
放在csproj中,而不是在packages.config文件中。 Does anyone know how I can force new Nuget packages in my .NET Standard 1.4 project to be listed in packages.config
instead of as Package References? 有谁知道我如何强制我的.NET Standard 1.4项目中的新Nuget包列在packages.config
而不是Package References中?
In addition to removing the PackageReferences from the project file, I also had to remove the following files from the $ProjectDir\\obj
directory: 除了从项目文件中删除PackageReferences之外,我还必须从$ProjectDir\\obj
目录中删除以下文件:
Close the migrated project. 关闭迁移的项目。
Copy the project file and packages.config from the backup (typically \\MigrationBackup\\\\) to the project folder. 将项目文件和packages.config从备份(通常为\\ MigrationBackup \\\\)复制到项目文件夹。 Delete the obj folder if it exists in the project root directory. 删除项目根目录中存在的obj文件夹。
Open the project. 打开项目。
Open the Package Manager Console using the Tools > NuGet Package Manager > Package Manager Console menu command. 使用工具> NuGet包管理器>包管理器控制台菜单命令打开包管理器控制台。
Run the following command in the Console: 在控制台中运行以下命令:
update-package -reinstall update-package -reinstall
Source: https://docs.microsoft.com/en-us/nuget/reference/migrate-packages-config-to-package-reference#how-to-roll-back-to-packagesconfig 来源: https : //docs.microsoft.com/en-us/nuget/reference/migrate-packages-config-to-package-reference#how-to-roll-back-to-packagesconfig
If you haven't already you need to remove this property: <RestoreProjectStyle>PackageReference</RestoreProjectStyle>
如果您还不需要删除此属性: <RestoreProjectStyle>PackageReference</RestoreProjectStyle>
And then remove any PackageReferences in your project. 然后删除项目中的任何PackageReferences。 Then when you add nuget package references they should go into the package.config file. 然后,当您添加nuget包引用时,它们应该进入package.config文件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.