-
Notifications
You must be signed in to change notification settings - Fork 654
Support for Visual Studio Online Build vNext - VSO Build Step #562
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 12 commits
fc69867
944e7ed
dc73c45
6556da0
957b04c
bbb62b2
18c894a
0a1cac1
07b1750
af6c891
eb40a66
5f5bd06
55069fc
21a6bed
a3060b8
0175005
62cf512
8aea193
67a0325
4b72005
b78725e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# Visual Studio Online (Build vNext) Setup | ||
## Basic Usage | ||
In [Visual Studio Online](https://www.visualstudio.com/) build vNext (the web based build system) you can add a build step as follows: | ||
|
||
* **Build Step:** Command Line | ||
* Might need to fully qualify the path. | ||
* Tip: Use a script and/or another command step to call `NuGet Install GitVersion.CommandLine` first so you don't have to check in the exe. | ||
* **Tool:** `GitVersion.exe` | ||
* **Arguments:** `/output buildserver /updateassemblyinfo true` | ||
|
||
Then in your build parameters simply [add a placeholder](#nuget-in-teamcity) of the GitVersion variables you would like to use. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This seems like copy/past from TeamCity documentation and not accurate for this PR |
||
|
||
GitVersion writes build parameters into VSO, so they will automatically be passed to your build scripts to use. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think this works at the moment |
||
|
||
## GitVersion Build Step for VSO | ||
Visual Studio Online has support for custom build steps. This is planned but TBD. For now, the command line does work. | ||
|
||
|
||
## Running inside TeamCity | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This seems like copy/past from TeamCity documentation and not accurate for this PR There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It was and it did work originally....will update! That's on the to do notes at the top :) |
||
* We output the individual values of the GitVersion version as the build parameter: `GitVersion.*` (Eg: `GitVersion.Major`) if you need access to them in your build script | ||
|
||
### NuGet in VSO | ||
* Add dummy parameter to the project called `GitVersion.NuGetVersion`. | ||
* Then setup you nuget pack build set the "version" to `%GitVersion.NuGetVersion%` | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
using GitVersion; | ||
using NUnit.Framework; | ||
|
||
[TestFixture] | ||
public class VsoAgentTests | ||
{ | ||
[Test] | ||
public void Develop_branch() | ||
{ | ||
var versionBuilder = new VsoAgent(); | ||
var vsVersion = versionBuilder.GenerateSetVersionMessage("0.0.0-Unstable4"); | ||
// Assert.AreEqual("##vso[task.setvariable variable=GitBuildNumber;]0.0.0-Unstable4", vsVersion); | ||
|
||
Assert.Null(vsVersion); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Minor thing, but using Shouldly will give much better error messages. I think I am going to move to xUnit so there is not the option for using the inbuilt assertions, not going to block PR though, I will cleanup later |
||
} | ||
|
||
[Test] | ||
public void EscapeValues() | ||
{ | ||
var versionBuilder = new VsoAgent(); | ||
var vsVersion = versionBuilder.GenerateSetParameterMessage("Foo", "0.8.0-unstable568 Branch:'develop' Sha:'ee69bff1087ebc95c6b43aa2124bd58f5722e0cb'"); | ||
Assert.AreEqual("##vso[task.setvariable variable=GitVersion.Foo;]0.8.0-unstable568 Branch:'develop' Sha:'ee69bff1087ebc95c6b43aa2124bd58f5722e0cb'", vsVersion[0]); | ||
|
||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<configuration> | ||
<runtime> | ||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> | ||
<dependentAssembly> | ||
<assemblyIdentity name="Mono.Cecil" publicKeyToken="0738eb9f132ed756" culture="neutral" /> | ||
<bindingRedirect oldVersion="0.0.0.0-0.9.6.0" newVersion="0.9.6.0" /> | ||
</dependentAssembly> | ||
</assemblyBinding> | ||
</runtime> | ||
</configuration> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
namespace GitVersion | ||
{ | ||
using System; | ||
|
||
public class VsoAgent : BuildServerBase | ||
{ | ||
public override bool CanApplyToCurrentContext() | ||
{ | ||
return !string.IsNullOrEmpty(Environment.GetEnvironmentVariable("TF_BUILD")); | ||
} | ||
|
||
public override string[] GenerateSetParameterMessage(string name, string value) | ||
{ | ||
return new[] | ||
{ | ||
string.Format("##vso[task.setvariable variable=GitVersion.{0};]{1}", name, value) | ||
}; | ||
} | ||
|
||
public override string GenerateSetVersionMessage(string versionToUseForBuildNumber) | ||
{ | ||
// Note: the VSO agent does not yet support updating the build display number from a variable | ||
return null; | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<configuration> | ||
<runtime> | ||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> | ||
<dependentAssembly> | ||
<assemblyIdentity name="Mono.Cecil" publicKeyToken="0738eb9f132ed756" culture="neutral" /> | ||
<bindingRedirect oldVersion="0.0.0.0-0.9.6.0" newVersion="0.9.6.0" /> | ||
</dependentAssembly> | ||
</assemblyBinding> | ||
</runtime> | ||
</configuration> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why command line when this PR is about a custom build step?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's old and needs to change. That refers to using GitVersion.exe as a standalone. That won't get past the detached head issues that the VSO build step does. I'll update the docs.