浏览代码

Build Ix with VSTS (#616)

* build with vsts

* update xunit with vsts support

* add versioning files

* fix test run

* stamp full hash in assembly
Oren Novotny 7 年之前
父节点
当前提交
29fa48f5a9

+ 50 - 0
.vsts.ix-ci.yml

@@ -0,0 +1,50 @@
+trigger:
+  branches:
+    include:
+      - master
+      - rel/*
+  paths:
+    include:
+      - Ix.NET/Source/*
+      - .editorconfig
+      - .vsts.ix-ci.yml
+      - NuGet.Config
+
+queue: Hosted VS2017
+
+variables: 
+  BuildConfiguration: Release
+  BuildPlatform: Any CPU
+    
+steps:
+- task: BatchScript@1
+  inputs:
+    filename: "C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Enterprise\\Common7\\Tools\\VsDevCmd.bat"
+    arguments: -no_logo
+    modifyEnvironment: true
+  displayName: Setup Environment Variables
+
+- task: DotNetCoreCLI@2
+  inputs:
+    command: build
+    projects: Ix.NET/Source/build/setversion.csproj
+    arguments: -c $(BuildConfiguration)   
+  displayName: Set Version
+   
+- task: PowerShell@1
+  inputs:
+    scriptName: 'Ix.NET/Source/build-new.ps1'
+    workingFolder: 'Ix.NET/Source'
+  env:
+    VSTS_ACCESS_TOKEN: $(System.AccessToken)
+    SignClientUser: $(SignClientUser)
+    SignClientSecret: $(SignClientSecret)
+    COVERALLS_REPO_TOKEN: $(CoverallsToken)
+  displayName: Build
+
+- task: PublishBuildArtifacts@1
+  inputs:
+    PathtoPublish: 'Ix.NET/Source/artifacts'
+    ArtifactName: artifacts
+    publishLocation: Container
+  condition: always()

+ 29 - 0
.vsts.ix-pr.yml

@@ -0,0 +1,29 @@
+trigger: none
+queue: Hosted VS2017
+
+variables: 
+  BuildConfiguration: Release
+  BuildPlatform: Any CPU
+    
+steps:
+- task: BatchScript@1
+  inputs:
+    filename: "C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Enterprise\\Common7\\Tools\\VsDevCmd.bat"
+    arguments: -no_logo
+    modifyEnvironment: true
+  displayName: Setup Environment Variables
+    
+- task: PowerShell@1
+  inputs:
+    scriptName: 'Ix.NET/Source/build-new.ps1'
+    workingFolder: 'Ix.NET/Source'
+  env:
+    VSTS_ACCESS_TOKEN: $(System.AccessToken)
+  displayName: Build
+
+- task: PublishBuildArtifacts@1
+  inputs:
+    PathtoPublish: 'Ix.NET/Source/artifacts'
+    ArtifactName: artifacts
+    publishLocation: Container
+  condition: eq(variables['system.pullrequest.isfork'], false)

+ 14 - 19
Ix.NET/Source/Directory.build.props

@@ -16,27 +16,22 @@
     <DefaultLanguage>en-US</DefaultLanguage>
     <IsTestProject>$(MSBuildProjectName.Contains('Test'))</IsTestProject>
     <DebugType>embedded</DebugType>
+    <EmbedUntrackedSources>true</EmbedUntrackedSources>
+    <PublishRepositoryUrl>true</PublishRepositoryUrl>
   </PropertyGroup>
-  
-  <ItemGroup Condition="'$(IsTestProject)' != 'true' and '$(SourceLinkEnabled)' != 'false'">
-    <PackageReference Include="SourceLink.Create.CommandLine" Version="2.6.0" PrivateAssets="All" /> 
-  </ItemGroup>
-  
-  <PropertyGroup>
-    <NerdbankGitVersioningVersion>2.0.41</NerdbankGitVersioningVersion>
-  </PropertyGroup>
-  
+    
   <ItemGroup>
-    <PackageReference Include="Nerdbank.GitVersioning" Version="2.0.41" PrivateAssets="all" />
+    <PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0-beta-62925-02" PrivateAssets="All"/>
+    <PackageReference Include="Nerdbank.GitVersioning" Version="2.1.23" PrivateAssets="all" />
   </ItemGroup>
+  
+  <Target Name="AddCommitHashToAssemblyAttributes" BeforeTargets="GetAssemblyAttributes">
+    <ItemGroup>
+      <AssemblyAttribute Include="System.Reflection.AssemblyMetadataAttribute" Condition=" '$(SourceRevisionId)' != '' ">
+        <_Parameter1>CommitHash</_Parameter1>
+        <_Parameter2>$(SourceRevisionId)</_Parameter2>
+      </AssemblyAttribute>
+    </ItemGroup>
+  </Target>
 
-  <!-- https://github.com/NuGet/Home/issues/4337 -->
-  <ImportGroup Condition=" '$(ExcludeRestorePackageImports)' == 'true' ">
-    <Import Project="$(NuGetPackageRoot)\nerdbank.gitversioning\$(NerdbankGitVersioningVersion)\buildCrossTargeting\Nerdbank.GitVersioning.targets"
-            Condition="Exists('$(NuGetPackageRoot)\nerdbank.gitversioning\$(NerdbankGitVersioningVersion)\buildCrossTargeting\Nerdbank.GitVersioning.targets')" />
-  </ImportGroup>
-  <Target Name="FixUpVersion"
-      BeforeTargets="_GenerateRestoreProjectSpec"
-      DependsOnTargets="GetBuildVersion"
-      Condition=" '$(NerdbankGitVersioningTasksPath)' != '' " />
 </Project>

+ 3 - 4
Ix.NET/Source/System.Interactive.Async.Tests/System.Interactive.Async.Tests.csproj

@@ -18,12 +18,11 @@
   </ItemGroup>
 
   <ItemGroup>
-    <PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.5.0" />
-    <PackageReference Include="xunit.runner.visualstudio" Version="2.3.1" />
+    <PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.7.2" />
+    <PackageReference Include="xunit.runner.visualstudio" Version="2.4.0-beta.2.build4010" />
     <PackageReference Include="FluentAssertions" Version="4.19.2 " />
 
-    <PackageReference Include="xunit" Version="2.3.1" />
-    <DotNetCliToolReference Include="dotnet-xunit" Version="2.3.1" />
+    <PackageReference Include="xunit" Version="2.4.0-beta.2.build4010" />
 
   </ItemGroup>
 

+ 3 - 5
Ix.NET/Source/System.Interactive.Tests/System.Interactive.Tests.csproj

@@ -17,13 +17,11 @@
   </ItemGroup>
 
   <ItemGroup>
-    <PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.5.0" />
-    <PackageReference Include="xunit.runner.visualstudio" Version="2.3.1" />
+    <PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.7.2" />
+    <PackageReference Include="xunit.runner.visualstudio" Version="2.4.0-beta.2.build4010" />
     <PackageReference Include="FluentAssertions" Version="4.19.2 " />
     
-    <PackageReference Include="xunit" Version="2.3.1" />
-    <DotNetCliToolReference Include="dotnet-xunit" Version="2.3.1" />
-
+    <PackageReference Include="xunit" Version="2.4.0-beta.2.build4010" />
   </ItemGroup>
 
 </Project>

+ 12 - 22
Ix.NET/Source/build-new.ps1

@@ -2,9 +2,8 @@ $scriptPath = split-path -parent $MyInvocation.MyCommand.Definition
 
 $configuration = "Release"
 
-$isAppVeyor = Test-Path -Path env:\APPVEYOR
+$isCloudBuild = Test-Path -Path env:\TF_BUILD
 $outputLocation = Join-Path $scriptPath "testResults"
-$xUnitConsolePath = ".\packages\xunit.runner.console\tools\net452\xunit.console.exe"
 $rootPath = (Resolve-Path .).Path
 $artifacts = Join-Path $rootPath "artifacts"
 
@@ -30,8 +29,7 @@ if (!(Test-Path .\nuget.exe)) {
 # get tools
 .\nuget.exe install -excludeversion SignClient -Version 0.9.0 -outputdirectory packages
 .\nuget.exe install -excludeversion JetBrains.dotCover.CommandLineTools -pre -outputdirectory packages
-.\nuget.exe install -excludeversion Nerdbank.GitVersioning -Version 2.0.41 -outputdirectory packages
-.\nuget.exe install -excludeversion xunit.runner.console -outputdirectory packages
+.\nuget.exe install -excludeversion Nerdbank.GitVersioning -Version 2.1.23 -outputdirectory packages
 .\nuget.exe install -excludeversion ReportGenerator -outputdirectory packages
 #.\nuget.exe install -excludeversion coveralls.io -outputdirectory packages
 .\nuget.exe install -excludeversion coveralls.io.dotcover -outputdirectory packages
@@ -45,13 +43,6 @@ Write-Host "Building $packageSemVer" -Foreground Green
 New-Item -ItemType Directory -Force -Path $artifacts
 
 
-Write-Host "Restoring packages for $scriptPath\Ix.NET.sln" -Foreground Green
-# use nuget.exe to restore on the legacy proj type
-#.\nuget.exe restore "$scriptPath\System.Interactive.Tests.Uwp.DeviceRunner\System.Interactive.Tests.Uwp.DeviceRunner.csproj"
-dotnet restore "$scriptPath\Ix.NET.sln" 
-# Force a restore again to get proper version numbers https://github.com/NuGet/Home/issues/4337
-dotnet restore "$scriptPath\Ix.NET.sln"
-
 Write-Host "Building $scriptPath\Ix.NET.sln" -Foreground Green
 
 # Using MSBuild here since th UWP test project cannot be built by the dotnet CLI
@@ -62,7 +53,7 @@ Write-Host "Building Packages" -Foreground Green
 dotnet pack "$scriptPath\System.Interactive\System.Interactive.csproj" -c $configuration /p:PackageOutputPath=$artifacts /p:NoPackageAnalysis=true
 if ($LastExitCode -ne 0) { 
         Write-Host "Error with build" -Foreground Red
-        if($isAppVeyor) {
+        if($isCloudBuild) {
           $host.SetShouldExit($LastExitCode)
           exit $LastExitCode
         }  
@@ -71,7 +62,7 @@ if ($LastExitCode -ne 0) {
 dotnet pack "$scriptPath\System.Interactive.Async\System.Interactive.Async.csproj" -c $configuration /p:PackageOutputPath=$artifacts /p:NoPackageAnalysis=true
 if ($LastExitCode -ne 0) { 
         Write-Host "Error with build" -Foreground Red
-        if($isAppVeyor) {
+        if($isCloudBuild) {
           $host.SetShouldExit($LastExitCode)
           exit $LastExitCode
         }  
@@ -80,7 +71,7 @@ if ($LastExitCode -ne 0) {
 dotnet pack "$scriptPath\System.Interactive.Async.Providers\System.Interactive.Async.Providers.csproj" -c $configuration /p:PackageOutputPath=$artifacts /p:NoPackageAnalysis=true
 if ($LastExitCode -ne 0) { 
         Write-Host "Error with build" -Foreground Red
-        if($isAppVeyor) {
+        if($isCloudBuild) {
           $host.SetShouldExit($LastExitCode)
           exit $LastExitCode
         }  
@@ -89,7 +80,7 @@ if ($LastExitCode -ne 0) {
 dotnet pack "$scriptPath\System.Interactive.Providers\System.Interactive.Providers.csproj" -c $configuration /p:PackageOutputPath=$artifacts /p:NoPackageAnalysis=true
 if ($LastExitCode -ne 0) { 
         Write-Host "Error with build" -Foreground Red
-        if($isAppVeyor) {
+        if($isCloudBuild) {
           $host.SetShouldExit($LastExitCode)
           exit $LastExitCode
         }  
@@ -106,7 +97,7 @@ if($hasSignClientSecret) {
 
     if ($LastExitCode -ne 0) { 
         Write-Host "Error signing $nupkg" -Foreground Red
-        if($isAppVeyor) {
+        if($isCloudBuild) {
           $host.SetShouldExit($LastExitCode)
           exit $LastExitCode
         }  
@@ -123,24 +114,23 @@ $testDirectory = Join-Path $scriptPath "System.Interactive.Tests"
 
 # OpenCover isn't working currently. So run tests on CI and coverage with JetBrains 
 
-# Use xUnit CLI as it's significantly faster than vstest (dotnet test)
 $dotnet = "$env:ProgramFiles\dotnet\dotnet.exe"
-.\packages\JetBrains.dotCover.CommandLineTools\tools\dotCover.exe cover /targetexecutable="$dotnet" /targetworkingdir="$testDirectory" /targetarguments="xunit -c $configuration" /Filters="+:module=System.Interactive;+:module=System.Interactive.Async;+:module=System.Interactive.Providers;+:module=System.Interactive.Async.Providers;-:type=Xunit*" /DisableDefaultFilters /ReturnTargetExitCode /AttributeFilters="System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverageAttribute" /output="$outputFileDotCover1"
+.\packages\JetBrains.dotCover.CommandLineTools\tools\dotCover.exe cover /targetexecutable="$dotnet" /targetworkingdir="$testDirectory" /targetarguments="test -c $configuration --filter `"SkipCI!=true`"" /Filters="+:module=System.Interactive;+:module=System.Interactive.Async;+:module=System.Interactive.Providers;+:module=System.Interactive.Async.Providers;-:type=Xunit*" /DisableDefaultFilters /ReturnTargetExitCode /AttributeFilters="System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverageAttribute" /output="$outputFileDotCover1"
 
 if ($LastExitCode -ne 0) { 
 	Write-Host "Error with tests" -Foreground Red
-	if($isAppVeyor) {
+	if($isCloudBuild) {
 	  $host.SetShouldExit($LastExitCode)
 	  exit $LastExitCode
 	}  
 }
 
 $testDirectory = Join-Path $scriptPath "System.Interactive.Async.Tests"  
-.\packages\JetBrains.dotCover.CommandLineTools\tools\dotCover.exe cover /targetexecutable="$dotnet" /targetworkingdir="$testDirectory" /targetarguments="xunit -c $configuration" /Filters="+:module=System.Interactive;+:module=System.Interactive.Async;+:module=System.Interactive.Providers;+:module=System.Interactive.Async.Providers;-:type=Xunit*" /DisableDefaultFilters /ReturnTargetExitCode /AttributeFilters="System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverageAttribute" /output="$outputFileDotCover2"
+.\packages\JetBrains.dotCover.CommandLineTools\tools\dotCover.exe cover /targetexecutable="$dotnet" /targetworkingdir="$testDirectory" /targetarguments="test -c $configuration --filter `"SkipCI!=true`"" /Filters="+:module=System.Interactive;+:module=System.Interactive.Async;+:module=System.Interactive.Providers;+:module=System.Interactive.Async.Providers;-:type=Xunit*" /DisableDefaultFilters /ReturnTargetExitCode /AttributeFilters="System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverageAttribute" /output="$outputFileDotCover2"
 
 if ($LastExitCode -ne 0) { 
 	Write-Host "Error with tests" -Foreground Red
-	if($isAppVeyor) {
+	if($isCloudBuild) {
 	  $host.SetShouldExit($LastExitCode)
 	  exit $LastExitCode
 	}  
@@ -150,7 +140,7 @@ if ($LastExitCode -ne 0) {
 .\packages\JetBrains.dotCover.CommandLineTools\tools\dotCover.exe report /Source="$outputFileDotCover" /Output="$outputFile" /ReportType=DetailedXML /HideAutoProperties
 
 # Either display or publish the results
-if ($env:CI -eq 'True')
+if ($isCloudBuild -eq 'True')
 {
   .\packages\coveralls.io.dotcover\tools\coveralls.net.exe  -p DotCover "$outputFile"
 }

+ 7 - 0
Ix.NET/Source/build/setversion.csproj

@@ -0,0 +1,7 @@
+<Project Sdk="Microsoft.NET.Sdk">
+
+  <PropertyGroup>
+    <TargetFramework>netstandard2.0</TargetFramework>
+  </PropertyGroup>
+
+</Project>

+ 8 - 0
Ix.NET/Source/build/version.json

@@ -0,0 +1,8 @@
+{
+  "inherit": true,
+  "cloudBuild": {
+    "buildNumber": {
+      "enabled": true
+    }
+  }
+}

+ 2 - 3
Ix.NET/Source/version.json

@@ -2,15 +2,14 @@
   "version": "3.2.0-preview.{height}",
   "publicReleaseRefSpec": [
     "^refs/heads/master$", // we release out of master
-    "^refs/heads/develop$", // we release out of develop
-    "^refs/tags/v\\d+\\.\\d+" // we also release tags starting with vN.N
+    "^refs/heads/rel/v\\d+\\.\\d+" // we also release branches starting with vN.N
   ],
   "nugetPackageVersion":{
     "semVer": 2
   },
   "cloudBuild": {
     "buildNumber": {
-      "enabled": true
+      "enabled": false
     }
   }
 }

+ 0 - 7
build.ps1

@@ -1,7 +0,0 @@
-$repositoryRoot = split-path $MyInvocation.MyCommand.Definition
-
-Write-Host "Building Rx.NET" -ForegroundColor Green
-.\Rx.NET\Source\build-new
-
-Write-Host "Building Ix.NET" -ForegroundColor Green
-.\Ix.NET\Source\build-new