Public/Get-NuspecSchema.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
function Get-NuspecSchema
{
    <#
        .SYNOPSIS
            Gets NuGet xsd schema for Nuspec file.
        .DESCRIPTION
            Gets NuGet xsd schema for Nuspec file from GitHub.
        .INPUTS
        .OUTPUTS
            System.String
            Returns a string containing the XSD content from Nuspec schema
        .EXAMPLE
            Get-NuspecSchema
 
            Description
            -----------
            This example connects to GitHub and retrieve xsd schema for Nuspec files.
        .NOTES
        .LINK
            https://docs.microsoft.com/en-us/nuget/reference/nuspec
        .LINK
            https://raw.githubusercontent.com/MyGet/NuGetPackages/master/NuSpec/tools/nuspec.xsd
    #>

    [CmdLetBinding()]
    param()
    try
    {
        Write-Verbose "Getting schema from 'https://raw.githubusercontent.com/MyGet/NuGetPackages/master/NuSpec/tools/nuspec.xsd'."
        (Invoke-WebRequest -Uri "https://raw.githubusercontent.com/MyGet/NuGetPackages/master/NuSpec/tools/nuspec.xsd" -ContentType "application/xml; charset=utf-8").Content.Replace("`r`n", "").replace("`n", "")
    }
    catch { Write-Error $_ }
}