Permalink
Browse files

Fixing build

  • Loading branch information...
1 parent eccef8a commit 26cff0e1393e3412540adef4ab1cdde5a867dffa @jbogard jbogard committed Nov 30, 2015
Showing with 57 additions and 41 deletions.
  1. +53 −5 default.ps1
  2. +4 −1 global.json
  3. +0 −35 psake.bat
View
@@ -10,11 +10,28 @@ properties {
task default -depends local
-task local -depends compile, test
+task local -depends init, compile, test
task ci -depends clean, release, local
task clean {
rd "$source_dir\artifacts" -recurse -force -ErrorAction SilentlyContinue | out-null
+ rd "$base_dir\build" -recurse -force -ErrorAction SilentlyContinue | out-null
+}
+
+task init {
+ $dnxVersion = Get-DnxVersion
+
+ # Remove the installed DNVM from the path and force use of
+ # per-user DNVM (which we can upgrade as needed without admin permissions)
+ Remove-PathVariable "*Program Files\Microsoft DNX\DNVM*"
+
+ # Make sure per-user DNVM is installed
+ Install-Dnvm
+
+ # Install DNX
+ dnvm install $dnxVersion -r CoreCLR -NoNative
+ dnvm install $dnxVersion -r CLR -NoNative
+ dnvm use $dnxVersion -r CLR
}
task release {
@@ -25,18 +42,49 @@ task compile -depends clean {
$env:DNX_BUILD_VERSION=$env:build_number
exec { dnu restore }
- exec { dnu build $source_dir\AutoMapper --configuration $config}
+ exec { dnu pack $source_dir\AutoMapper --configuration $config}
exec { & $base_dir\.nuget\Nuget.exe restore $source_dir\AutoMapper.NoProjectJson.sln }
exec { msbuild /t:Clean /t:Build /p:Configuration=$config /v:q /p:NoWarn=1591 /nologo $source_dir\AutoMapper.sln }
}
task test {
- create_directory "$build_dir\results"
+ mkdir $result_dir
exec { & $source_dir\packages\Fixie.1.0.0.33\lib\Net45\Fixie.Console.exe --xUnitXml $result_dir\AutoMapper.UnitTests.Net4.xml $source_dir/UnitTests/bin/$config/AutoMapper.UnitTests.Net4.dll }
exec { & $source_dir\packages\Fixie.1.0.0.33\lib\Net45\Fixie.Console.exe --xUnitXml $result_dir\AutoMapper.IntegrationTests.Net4.xml $source_dir/IntegrationTests.Net4/bin/$config/AutoMapper.IntegrationTests.Net4.dll }
}
-function global:create_directory($directory_name)
+function Install-Dnvm
+{
+ & where.exe dnvm 2>&1 | Out-Null
+ if(($LASTEXITCODE -ne 0) -Or ((Test-Path Env:\TEAMCITY_VERSION) -eq $true))
+ {
+ Write-Host "DNVM not found"
+ &{$Branch='dev';iex ((New-Object net.webclient).DownloadString('https://raw.githubusercontent.com/aspnet/Home/dev/dnvminstall.ps1'))}
+
+ if($env:DNX_HOME -eq $NULL)
+ {
+ Write-Host "Initial DNVM environment setup failed; running manual setup"
+ $tempDnvmPath = Join-Path $env:TEMP "dnvminstall"
+ $dnvmSetupCmdPath = Join-Path $tempDnvmPath "dnvm.ps1"
+ & $dnvmSetupCmdPath setup
+ }
+ }
+}
+
+function Get-DnxVersion
+{
+ $globalJson = Join-Path $PSScriptRoot "global.json"
+ $jsonData = Get-Content -Path $globalJson -Raw | ConvertFrom-JSON
+ return $jsonData.sdk.version
+}
+
+function Remove-PathVariable
{
- mkdir $directory_name -ErrorAction SilentlyContinue | out-null
+ param([string] $VariableToRemove)
+ $path = [Environment]::GetEnvironmentVariable("PATH", "User")
+ $newItems = $path.Split(';') | Where-Object { $_.ToString() -inotlike $VariableToRemove }
+ [Environment]::SetEnvironmentVariable("PATH", [System.String]::Join(';', $newItems), "User")
+ $path = [Environment]::GetEnvironmentVariable("PATH", "Process")
+ $newItems = $path.Split(';') | Where-Object { $_.ToString() -inotlike $VariableToRemove }
+ [Environment]::SetEnvironmentVariable("PATH", [System.String]::Join(';', $newItems), "Process")
}
View
@@ -1,3 +1,6 @@
{
- "sources": [ "src\\AutoMapper" ]
+ "projects": [ "src\\AutoMapper", "test" ],
+ "sdk": {
+ "version": "1.0.0-rc1-final"
+ }
}
View
@@ -2,41 +2,6 @@
cd %~dp0
SETLOCAL
-SET NUGET_VERSION=latest
-SET CACHED_NUGET=%LocalAppData%\NuGet\nuget.%NUGET_VERSION%.exe
-SET BUILDCMD_KOREBUILD_VERSION=
-SET BUILDCMD_DNX_VERSION=
-
-IF EXIST %CACHED_NUGET% goto copynuget
-echo Downloading latest version of NuGet.exe...
-IF NOT EXIST %LocalAppData%\NuGet md %LocalAppData%\NuGet
-@powershell -NoProfile -ExecutionPolicy unrestricted -Command "$ProgressPreference = 'SilentlyContinue'; Invoke-WebRequest 'https://dist.nuget.org/win-x86-commandline/%NUGET_VERSION%/nuget.exe' -OutFile '%CACHED_NUGET%'"
-
-:copynuget
-IF EXIST .nuget\nuget.exe goto restore
-md .nuget
-copy %CACHED_NUGET% .nuget\nuget.exe > nul
-
-:restore
-IF EXIST packages\Sake goto getdnx
-IF "%BUILDCMD_KOREBUILD_VERSION%"=="" (
- .nuget\nuget.exe install KoreBuild -ExcludeVersion -o packages -nocache -pre
-) ELSE (
- .nuget\nuget.exe install KoreBuild -version %BUILDCMD_KOREBUILD_VERSION% -ExcludeVersion -o packages -nocache -pre
-)
-.nuget\NuGet.exe install Sake -ExcludeVersion -Source https://www.nuget.org/api/v2/ -Out packages
-
-:getdnx
-IF "%BUILDCMD_DNX_VERSION%"=="" (
- SET BUILDCMD_DNX_VERSION=latest
-)
-IF "%SKIP_DNX_INSTALL%"=="" (
- CALL packages\KoreBuild\build\dnvm install %BUILDCMD_DNX_VERSION% -runtime CoreCLR -arch x86 -alias default
- CALL packages\KoreBuild\build\dnvm install default -runtime CLR -arch x86 -alias default
-) ELSE (
- CALL packages\KoreBuild\build\dnvm use default -runtime CLR -arch x86
-)
-
powershell.exe -NoProfile -ExecutionPolicy unrestricted -Command "& {Import-Module '.\tools\psake\psake.psm1'; invoke-psake .\default.ps1 %*; if ($lastexitcode -ne 0) {write-host "ERROR: $lastexitcode" -fore RED; exit $lastexitcode} }"

0 comments on commit 26cff0e

Please sign in to comment.