Skip to content

Commit

Permalink
script and nuspec file to publish file to our nuget server
Browse files Browse the repository at this point in the history
  • Loading branch information
rickardliljeberg committed Nov 10, 2020
1 parent f2f74b2 commit d7b911b
Show file tree
Hide file tree
Showing 2 changed files with 126 additions and 0 deletions.
94 changes: 94 additions & 0 deletions BuildAndUploadLibrary.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
$lastVersion = "";

$nuspecContent = Get-Content -Path ".\Microsoft.SystemForCrossDomainIdentityManagement\Microsoft.SCIM.nuspec" -raw


$versionMatch = [regex]::Match($nuspecContent,'<version>(.*)</version>')

if(!$versionMatch.Success)
{
throw 'Previous version not found in nuspec file. Make sure it looks like this <version>x.x.x</version>'
}

$lastVersionString = $versionMatch.Groups[1].Value

try{

$lastVersion = [version]($lastVersionString)

}
catch {
Write-Host $_ -BackgroundColor Black -ForegroundColor Red
Write-Host "Incorrect format of version in nuspec file"
Read-Host -Prompt "Enter to exit"
exit
}

$automaticVersionToUse = "1.0.0"
if(![string]::IsNullOrEmpty($lastVersion))
{
$automaticVersionToUse = "{0}.{1}.{2}" -f $lastVersion.Major, $lastVersion.Minor, ($lastVersion.Build + 1)
}

$manualVersion = Read-Host -Prompt "OPTIONAL: Manual version number (Press enter for automatic - $automaticVersionToUse)"

$newVersion = $automaticVersionToUse;
if(![string]::IsNullOrEmpty($manualVersion))
{
try{
$splitManual = [System.Version]::Parse($manualVersion)
}
catch {
Write-Host $_ -BackgroundColor Black -ForegroundColor Red
Write-Host "Incorrect format of given version - Should have format Major.Minor.Build so for instance 1.0.2"
Read-Host -Prompt "Enter to exit"
exit
}
$newVersion = $manualVersion;
}


$releaseNotes = Read-Host -Prompt "Release notes"

$releaseNotesMatch = [regex]::Match($nuspecContent,'<releaseNotes>.*</releaseNotes>')

if(!$releaseNotesMatch.Success)
{
throw 'release notes not found in nuspec file. Make sure it looks like this <releaseNotes>xxxxxxxx</releaseNotes>'
}

$lastReleaseNotesString = $releaseNotesMatch.Value

Set-Content -Path ".\Microsoft.SystemForCrossDomainIdentityManagement\Microsoft.SCIM.nuspec" -Value $($nuspecContent -replace $("<version>$($lastVersionString)</version>"),$("<version>$($newVersion)</version>") -replace $lastReleaseNotesString,"<releaseNotes>$($releaseNotes)</releaseNotes>")

dotnet build ".\Microsoft.SystemForCrossDomainIdentityManagement\Microsoft.SCIM.csproj" --configuration Release -p:Version=$newVersion

..\nuget.exe pack .\Microsoft.SystemForCrossDomainIdentityManagement\Microsoft.SCIM.csproj -Properties Configuration=Release

Write-Host "Press enter to push to nuget server (or close to not push)" -BackgroundColor Black -ForegroundColor Cyan
Read-Host

$nugetApiKey = ""

if([System.IO.File]::Exists(".\NugetKey.txt"))
{
$nugetApiKey = Get-Content -Path .\NugetKey.txt -First 1
}
else
{
Write-Host $_ -BackgroundColor Black -ForegroundColor Red
Write-Host "There must be a NugetKey.txt in the same directory as this build script that contains only the api key to the nuget server"
Read-Host -Prompt "Enter to exit"
exit
}

$packages = gci ".\*.nupkg"
foreach ($package in $packages){
$packageLocation = ".\" + $package.Name
..\nuget.exe push $packageLocation $nugetApiKey -Source http://nuget.evercate.com/nuget

Remove-Item –path $packageLocation
}


Read-Host -Prompt "Enter to exit"
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="utf-8"?>
<package >
<metadata>
<id>Evercate.Microsoft.Scim</id>
<version>1.0.0</version>
<title>Evercate scim based on Microsoft reference code</title>
<authors>Evercate AB</authors>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>A direkt fork from Microsoft's reference scim code. Only neccesary updates will be done</description>
<releaseNotes>initial release</releaseNotes>
<copyright>Copyright 2020</copyright>
<tags>microsoft evercate scim</tags>
</metadata>
</package>


















0 comments on commit d7b911b

Please sign in to comment.