一种清理csproj文件中的Nuget包的方法?

时间:2022-08-11 00:15:17

As I add and remove references sometimes I don't always "uninstall" a package which appears like a reference. So it remains "installed" in the Nuget package explorer. It seem like I could really use something that cleans up the .csproj and the packages.config file -- is there something that does this?

随着我添加和删除引用,有时我并不总是“卸载”一个看起来像引用的包。所以它仍然在Nuget包资源管理器中“安装”。看起来我真的可以使用清理.csproj和packages.config文件的东西 - 有什么能做到的吗?

This would be useful for both Visual Studio (VS) 2010 and VS 2012.

这对Visual Studio(VS)2010和VS 2012都很有用。

2 个解决方案

#1


0  

Uninstalling a package should be done as an explicit gesture.

卸载程序包应该作为显式手势完成。

If you want to know if a particular reference is part of a package, you can check the Path of the reference. If the hint path is something like "..\Packages\.." , you will know that the reference is part of a package.

如果您想知道特定引用是否是包的一部分,可以检查引用的路径。如果提示路径类似于“.. \ Packages \ ..”,您将知道该引用是包的一部分。

#2


0  

I'm also looking for a tool to help with cleaning up the packages and at least identify unused Nuget packages for me. For now the manual way to check that a package is used or not is to uninstall the package and compile the project. If everything is still passing that means the package is not used. If things failed you can simply revert the changes in your source control system. You will need to repeat these steps for each package installed in your Visual Studio solution.

我也在寻找一种工具来帮助清理包装,至少为我识别未使用的Nuget包。现在,检查包是否使用的手动方法是卸载包并编译项目。如果一切仍在传递,则意味着不使用包。如果事情失败,您只需还原源控制系统中的更改即可。您需要为Visual Studio解决方案中安装的每个包重复这些步骤。

#1


0  

Uninstalling a package should be done as an explicit gesture.

卸载程序包应该作为显式手势完成。

If you want to know if a particular reference is part of a package, you can check the Path of the reference. If the hint path is something like "..\Packages\.." , you will know that the reference is part of a package.

如果您想知道特定引用是否是包的一部分,可以检查引用的路径。如果提示路径类似于“.. \ Packages \ ..”,您将知道该引用是包的一部分。

#2


0  

I'm also looking for a tool to help with cleaning up the packages and at least identify unused Nuget packages for me. For now the manual way to check that a package is used or not is to uninstall the package and compile the project. If everything is still passing that means the package is not used. If things failed you can simply revert the changes in your source control system. You will need to repeat these steps for each package installed in your Visual Studio solution.

我也在寻找一种工具来帮助清理包装,至少为我识别未使用的Nuget包。现在,检查包是否使用的手动方法是卸载包并编译项目。如果一切仍在传递,则意味着不使用包。如果事情失败,您只需还原源控制系统中的更改即可。您需要为Visual Studio解决方案中安装的每个包重复这些步骤。