我正在尝试通过NuGet安装更新:
import xml.etree.ElementTree as et
import sys
import io
import string
import codecs
print("using texttool_navi.py" + sXmlFile)
#intializing Variables
sAddress = ''
sAcronym = ''
sPlace = ''
sData = ''
# parse texttool file
Parser =et
tree = et.parse(sXmlFile)
root = tree.getroot()
for child in root:
if child.attrib["ID"] == sID:
schild = et.tostring(child,encoding = 'utf-8')
print('line ' + schild)
sData = child.text
sData = string.split(sData, '"')
print(sData)
sAddress = sData[1]
sAcronym = sData[3]
sPlace = sData[5]
if sID == 'a specific ID':
sAddress = string.replace(sAddress, '\\n', ' ')
sAcronym = string.replace(sAcronym, '\\n', ' ')
sPlace = string.replace(sPlace, '\\n', ' ')
但是,更新永远不会成功,因为它在遇到以下冲突后回滚:
Microsoft.AspNetCore.Mvc 1.1.2 --> 2.0.4
因此,根据我的理解,Version conflict detected for Microsoft.CodeAnalysis.CSharp. Reference the package directly from the project to resolve this issue.
Web -> Microsoft.AspNetCore.Mvc 2.0.4 -> Microsoft.AspNetCore.Mvc.RazorPages 2.0.4 ->
Microsoft.AspNetCore.Mvc.Razor 2.0.4 -> Microsoft.CodeAnalysis.CSharp (>= 2.3.1)
Web -> Microsoft.VisualStudio.Web.CodeGeneration.Design 1.1.0 ->
Microsoft.VisualStudio.Web.CodeGeneration.Utils 1.1.0 ->
Microsoft.CodeAnalysis.CSharp.Workspaces 1.3.0 ->
Microsoft.CodeAnalysis.CSharp (= 1.3.0).
是罪魁祸首,因为Microsoft.CodeAnalysis.CSharp
具有依赖关系,要求它至少为Microsoft.AspNetCore.Mvc
,而v2.3.1
也有依赖关系它是Microsoft.VisualStudio.Web.CodeGeneration.Design
我不确定如何解决这个问题。它确实说v1.3.0
但我真的不明白这意味着什么以及如何做到这一点。
答案 0 :(得分:1)
如果直接添加依赖包(在这种情况下,将NuGet包Microsoft.CodeAnalysis.CSharp
添加到项目中),Visual Studio将使用直接引用包的版本,而不是其他包的依赖关系中指定的版本。 。这样,您已经指定了如何通过安装特定版本的依赖项来解决冲突。
您可以像其他任何NuGet软件包一样添加此引用:在VisualStudio中,右键单击项目->“管理NuGet软件包...”,搜索Microsoft.CodeAnalysis.CSharp
并安装它。
答案 1 :(得分:0)
如果您有用于还原所有Nuget的项目的“程序包”目录,则可以使用PowerShell脚本快速检查多个Nuget版本冲突:
$dir = "C:\packages"
$nugets = Get-ChildItem -Path $dir -Directory | ?{ $_.PSIsContainer } | ForEach-Object { $_.Name }
$nCount = $nugets.Count
Write-Host "Found $nCount nuggets in '$dir' direcotry"
$nugetObjects = $nugets | %{ [pscustomobject]@{ Name = $_ -replace '\.([0-9]).*([0-9])$'; Version = $_ -replace '^([A-Za-z]).*([A-Za-z])\.' }} | Group-Object "Name"
$conflicts = $nugetObjects | Where-Object {$_.Count -gt 1}
if ($conflicts.Count -gt 0) {
Write-Host "Found Nuget multiuple versions"
$conflicts
}
else {
Write-Host "Jey - Not found any Nuget version conflicts"
}