删除文件夹&使用 NuGet/Powershell 来自项目的文件
我试图在 NuGet 包安装期间从项目中删除 App_Start 文件夹。 NuGet 的文档位于:
http://nuget.codeplex.com/wikipage?title=Creating%20a% 20Package
说:
$project.Object 相当于 http://msdn.microsoft.com/en-us /library/ms170626.aspx.
我找不到该界面的太多信息,这对我有很大帮助。
我有以下 Powershell 脚本,它成功删除文件夹和文件:(
param($installPath, $toolsPath, $package, $project)
$DirInfo = New-Object System.IO.DirectoryInfo($installPath)
$appDir = New-Object System.IO.DirectoryInfo($DirInfo.Parent.Parent.FullName)
$fullPath = [IO.Path]::Combine($appDir.FullName, $appDir.Name, "App_start")
Remove-Item $fullPath -recurse
我知道不能保证此处的路径,但此包仅供内部使用)
但该项目仍然引用项目,因此这些项目会显示黄色警告,因为 Visual Studio 认为这些项目是项目的一部分。
我需要的是一种以编程方式从项目中删除对这些项目的引用的方法。有什么想法吗?
I am trying to remove the App_Start folder from my project during my NuGet package install. The documentation for NuGet here:
http://nuget.codeplex.com/wikipage?title=Creating%20a%20Package
Says:
$project.Object is the equivalent of http://msdn.microsoft.com/en-us/library/ms170626.aspx.
Which I am not able to find much information of that interface that is of much help to me.
I have the following Powershell script which successfully removes the folder and files:
param($installPath, $toolsPath, $package, $project)
$DirInfo = New-Object System.IO.DirectoryInfo($installPath)
$appDir = New-Object System.IO.DirectoryInfo($DirInfo.Parent.Parent.FullName)
$fullPath = [IO.Path]::Combine($appDir.FullName, $appDir.Name, "App_start")
Remove-Item $fullPath -recurse
(I know the pathing here isn't guaranteed, but this package is for internal use only)
But the project still has a reference to the items and therefore the items appear with the yellow warning because Visual Studio believes that the items are part of the project.
What I need is a way to remove a reference to those items from the project programatically. Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好吧,我绝对确定有比这更好的方法,但直到今天我才使用过 NuGet 或 Powershell...:/
我刚刚在我的包管理器控制台中运行了这个:
它循环遍历所有项目项,寻找顶部- 级别项目称为“控制器”,然后将其从项目中删除。很确定您可以将其更改为“App_Code”。
编辑:我的朋友(他比我更了解 Powershell)发送了以下内容:
Ok, I'm absolutely sure there's a better way than this, but I've never used NuGet or Powershell until today... :/
I just ran this in my Package Manager Console:
It looped through all projects items looking for a top-level item called "Controllers" and then removed it from the project. Pretty sure you could just change this to "App_Code".
Edit: Friend of mine (who knows a little more Powershell than me) sent this: