Validate NuGet package names with the NuGet API
This commit is contained in:
parent
39720da733
commit
cbcb942e57
@ -41,6 +41,36 @@
|
||||
end
|
||||
|
||||
|
||||
local validatedPackages = {}
|
||||
|
||||
function nuget2010.validatePackages(prj)
|
||||
if #prj.nuget == 0 then
|
||||
return
|
||||
end
|
||||
|
||||
for _, package in ipairs(prj.nuget) do
|
||||
local id = nuget2010.packageId(package)
|
||||
local version = nuget2010.packageVersion(package)
|
||||
|
||||
if not validatedPackages[id] then
|
||||
printf("Examining NuGet package '%s'...", id)
|
||||
io.flush()
|
||||
|
||||
local response, err, code = http.get(string.format("https://api.nuget.org/v3/registration1/%s/index.json", id:lower()))
|
||||
|
||||
if err ~= "OK" then
|
||||
if code == 404 then
|
||||
p.error("NuGet package '%s' for project '%s' couldn't be found in the repository", id, prj.name)
|
||||
else
|
||||
p.error("NuGet API error (%d)\n%s", code, err)
|
||||
end
|
||||
end
|
||||
end
|
||||
validatedPackages[id] = package
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Generates the packages.config file.
|
||||
--
|
||||
|
@ -61,6 +61,7 @@
|
||||
m.actionSupportsKind,
|
||||
m.projectRulesExist,
|
||||
m.projectValuesInScope,
|
||||
m.projectNuGetPackages,
|
||||
}
|
||||
end
|
||||
|
||||
@ -223,6 +224,11 @@
|
||||
end
|
||||
|
||||
|
||||
function m.projectNuGetPackages(prj)
|
||||
p.vstudio.nuget2010.validatePackages(prj)
|
||||
end
|
||||
|
||||
|
||||
function m.uniqueProjectIds(wks)
|
||||
local uuids = {}
|
||||
for prj in p.workspace.eachproject(wks) do
|
||||
|
Loading…
Reference in New Issue
Block a user