所以在我的 Install.ps1 中,我可以添加这样的引用:
So in my Install.ps1 I can add a reference like this:
param($installPath, $toolsPath, $package, $project) $project.Object.References.Add("YourDLL")如何在 PowerShell 中删除项目引用?
How do you remove a project reference in PowerShell?
推荐答案在 powershell 中执行此操作存在一些强制转换问题.
There are some casting issues to do this in powershell.
这是删除引用的 c#.
this is the c# to remove a reference.
DTE dte = (DTE)dteObject; var targetProject = (VSProject)dte.GetProject(target).Object; var refToRemove = targetProject.References.Cast<Reference>().Where(assembly => assembly.Name.EndsWith(library, System.StringComparison.InvariantCultureIgnoreCase)).FirstOrDefault(); if (refToRemove != null) { refToRemove.Remove(); }如果您想使用解决方案工厂 nuget 包,您可以使用解决方案工厂添加的 powershell 命令.
If you want to use the Solution Factory nuget package you can use the powershell command that solution factory adds.
Remove-LibraryReference projectName system.web这是解决方案工厂源的链接 solutionfactory.codeplex/SourceControl/network/Forks/erihexter/PowershellRewrite
Here is a link the the solution factory source solutionfactory.codeplex/SourceControl/network/Forks/erichexter/PowershellRewrite
更新:解决方案工厂的新网址:github/erichexter/SolutionFactory
Update: new url for solution factory: github/erichexter/SolutionFactory
更多推荐
NuGet Uninstall.ps1
发布评论