我正在尝试为我的angular2应用程序使用PowerShell 2编写自动化的构建和部署脚本,但是鉴于我们的ASP.NET Web API的使用方式api/,我想删除所有旧的角度代码而不接触API。
到目前为止,这是我得到的:
Get-ChildItem -Path $destination -Recurse -exclude somefile.txt |
Select -ExpandProperty FullName |
Where {$_ -notlike $destination+'\api*'} |
sort length -Descending |
Remove-Item -force -recurse
Run Code Online (Sandbox Code Playgroud)
$destination 是应用程序的安装目录。
快速文件夹树,以防我在上方不清楚:
$destination
api\
app\
assets\
vendor\
index.html
main.js
system-config.js
Run Code Online (Sandbox Code Playgroud)
如上所述,除了 api\
我无权使用PowerShell2。但是,使用PowerShell 3(及更高版本),您应该可以通过使用以下代码来简化代码:
$path = "C:\test path"
Remove-Item $path -recurse -Exclude "api"
Run Code Online (Sandbox Code Playgroud)
我假设api,app,asset和vendor是子文件夹,创建了与您指定的文件夹结构相同的文件夹。我在PowerShell IDE中运行了该脚本,它删除了测试路径下除api文件夹以外的所有内容。我假设PowerShell 2在命令上支持相同的参数。
| 归档时间: |
|
| 查看次数: |
12575 次 |
| 最近记录: |