Skip to content

Commit

Permalink
Update package.ps1 for new build
Browse files Browse the repository at this point in the history
  • Loading branch information
mellinoe committed Apr 27, 2016
1 parent 5c2d39e commit 307140b
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 21 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -248,4 +248,7 @@ tools/
*.ncrunchsolution

#dotnet cli
[Dd]otnet/
[Dd]otnet/

# Nuget.exe
nuget.exe
2 changes: 1 addition & 1 deletion build.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ if not defined VisualStudioVersion (
goto :Build
)

echo Error: cibuild.cmd requires Visual Studio 2015.
echo Error: build.cmd requires Visual Studio 2015.
exit /b 1
)

Expand Down
17 changes: 17 additions & 0 deletions package.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
@echo off
setlocal

:: Invoke VS Developer Command Prompt batch file.
:: This sets up some environment variables needed to use ILDasm and ILAsm.
if not defined VisualStudioVersion (
if defined VS140COMNTOOLS (
call "%VS140COMNTOOLS%\VsDevCmd.bat"
goto :Package
)

echo Error: package.cmd requires Visual Studio 2015.
exit /b 1
)

:Package
powershell -NoProfile %~dp0scripts\package.ps1 %*
19 changes: 0 additions & 19 deletions package.ps1

This file was deleted.

44 changes: 44 additions & 0 deletions scripts/package.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
Param(
[string]$Configuration="Debug",
[string]$ApiKey
)

$repoRoot = "$PSScriptRoot\.."
$dotnetExePath="$repoRoot\dotnet\dotnet.exe"
$nugetPath = "$repoRoot\nuget\nuget.exe"
$packagesPath = "$repoRoot\packages"

Function Ensure-Nuget-Exists {
if (!(Test-Path "$nugetPath")) {
if (!(Test-Path "$repoRoot\nuget")) {
New-Item -ItemType directory -Path "$repoRoot\nuget"
}
Write-Host "nuget.exe not found. Downloading to $nugetPath"
Invoke-WebRequest "https://nuget.org/nuget.exe" -OutFile $nugetPath
}
}

Write-Host "** Building all NuGet packages. **"
foreach ($file in [System.IO.Directory]::EnumerateFiles("$repoRoot\src", "project.json", "AllDirectories")) {
Write-Host "Creating NuGet package for $file..."
Invoke-Expression "$dotnetExePath pack $file -c $Configuration -o $packagesPath"

if (!$?) {
Write-Error "Failed to create NuGet package for project $file"
}
}

if ($ApiKey)
{
Ensure-Nuget-Exists
foreach ($file in [System.IO.Directory]::EnumerateFiles("$packagesPath", "*.nupkg")) {
try {
Write-Host "Pushing package $file to MyGet..."
$arguments = "push $file $apiKey -Source https://dotnet.myget.org/F/dotnet-corefxlab/api/v2/package"
Start-Process -FilePath $nugetPath -ArgumentList $arguments -Wait -PassThru
Write-Host "done"
} catch [System.Exception] {
Write-Host "Failed to push nuget package $file with error $_.Exception.Message"
}
}
}

0 comments on commit 307140b

Please sign in to comment.