所以在我的Install.ps1中,我可以像这样添加一个引用:
param($installPath, $toolsPath, $package, $project)
$project.Object.References.Add("YourDLL")
Run Code Online (Sandbox Code Playgroud)
如何在PowerShell中删除项目引用?
Ale*_*roß 14
这是我们用于Machine.Specifications的内容:
param($installPath, $toolsPath, $package, $project)
$project.Object.References | Where-Object { $_.Name -eq 'Machine.Specifications.TDNetRunner' } | ForEach-Object { $_.Remove() }
Run Code Online (Sandbox Code Playgroud)
在PowerShell中有一些强制转换问题.
这是删除引用的c#.
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();
}
Run Code Online (Sandbox Code Playgroud)
如果要使用Solution Factory nuget包,可以使用解决方案工厂添加的powershell命令.
Remove-LibraryReference projectName system.web
Run Code Online (Sandbox Code Playgroud)
这是解决方案工厂源代码的链接http://solutionfactory.codeplex.com/SourceControl/network/Forks/erichexter/PowershellRewrite
更新:解决方案工厂的新网址:https: //github.com/erichexter/SolutionFactory
| 归档时间: |
|
| 查看次数: |
3213 次 |
| 最近记录: |