Car*_*las 17 nuget .net-core visual-studio-code
我正在尝试更新所有NuGet包以获取VS Code中的解决方案(使用Mac).有没有办法在VS代码或特定的project.json文件中实现?目前我一个接一个地去,但我原本以为有一个扩展或功能为你做到了吗?
Rol*_*els 17
基于 Jon Canning 的 powershell 解决方案。我修复了一个小错误,其中只更新了第一个依赖项,而不是项目文件的所有依赖项。
$regex = 'PackageReference Include="([^"]*)" Version="([^"]*)"'
ForEach ($file in get-childitem . -recurse | where {$_.extension -like "*proj"})
{
$packages = Get-Content $file.FullName |
select-string -pattern $regex -AllMatches |
ForEach-Object {$_.Matches} |
ForEach-Object {$_.Groups[1].Value.ToString()}|
sort -Unique
ForEach ($package in $packages)
{
write-host "Update $file package :$package" -foreground 'magenta'
$fullName = $file.FullName
iex "dotnet add $fullName package $package"
}
}
Run Code Online (Sandbox Code Playgroud)
bri*_*ler 11
更新 2023/01
当前从命令行执行此操作的方法似乎是这样的:
https://github.com/dotnet-outdated/dotnet-outdated
老的
dotnet tool install nukeeper --global
nukeeper update <SLN/PROJ>
Run Code Online (Sandbox Code Playgroud)
更新
默认设置nukeeper对我来说似乎有点奇怪,因为运行nukeeper update只会更新单个包,并且仅当它是超过 3 天的主要版本时才更新。
要更新到所有运行的最新非预发布版本:
nukeeper update -a 0 -m 1000
Run Code Online (Sandbox Code Playgroud)
对于预发布:
nukeeper update -a 0 -m 1000 --useprerelease Always
Run Code Online (Sandbox Code Playgroud)
该-m 1000标志是所有内容的同义词,假设您的解决方案/项目中的包少于 1000 个。
Ali*_*adi 10
对于更新所有项目中的所有包,nuget 包管理器 gui扩展可以一键完成。
这个怎么运作
Load Package VersionsUpdate All Packages这是将执行此操作的Shell脚本和Powershell脚本
#!/bin/bash
regex='PackageReference Include="([^"]*)" Version="([^"]*)"'
find . -name "*.*proj" | while read proj
do
while read line
do
if [[ $line =~ $regex ]]
then
name="${BASH_REMATCH[1]}"
version="${BASH_REMATCH[2]}"
if [[ $version != *-* ]]
then
dotnet add $proj package $name
fi
fi
done < $proj
done
Run Code Online (Sandbox Code Playgroud)
$regex = [regex] 'PackageReference Include="([^"]*)" Version="([^"]*)"'
ForEach ($file in get-childitem . -recurse | where {$_.extension -like "*proj"})
{
$proj = $file.fullname
$content = Get-Content $proj
$match = $regex.Match($content)
if ($match.Success) {
$name = $match.Groups[1].Value
$version = $match.Groups[2].Value
if ($version -notin "-") {
iex "dotnet add $proj package $name"
}
}
}
Run Code Online (Sandbox Code Playgroud)
还应该提到Paket是支持更新的出色替代软件包管理器:
https://fsprojects.github.io/Paket/index.html
dotnet tool install paket --tool-path .paket
| 归档时间: |
|
| 查看次数: |
4856 次 |
| 最近记录: |