Skip to content

Commit 5fd5b13

Browse files
committed
Merge branch 'master' into UseCsProjPackaging
2 parents b726f95 + 8a601b4 commit 5fd5b13

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+3357
-499
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,9 @@ packages
134134
*.nuget.targets
135135
project.lock.json
136136

137+
# NPM
138+
package-lock.json
139+
137140
## TODO: If the tool you use requires repositories.config
138141
## uncomment the next line
139142
#!packages/repositories.config

appveyor.yml

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
1-
version: 99.0.{build}
1+
version: '{build}'
2+
branches:
3+
only:
4+
- master
5+
- /^v\d+(?:\.\d+)?$/
6+
- /[\b_]validate\b/
27
skip_tags: true
8+
skip_commits:
9+
files:
10+
- doc/*
11+
- readme.md
12+
nuget:
13+
disable_publish_on_pr: true
314
os: Visual Studio 2017
415
configuration: Release
516
cache:
@@ -22,6 +33,10 @@ before_build:
2233
build_script:
2334
- ps: >-
2435
.\build.ps1
36+
test:
37+
assemblies:
38+
only:
39+
- NerdBank.GitVersioning.Tests.dll
2540
artifacts:
2641
- path: bin\**\*.nupkg
2742
- path: bin\js\*.tgz

doc/cloudbuild.md

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@ in MSBuild, gulp and other build scripts.
1414
## Optional features
1515

1616
By specifying certain `cloudBuild` options in your `version.json` file,
17-
you can activate features for some cloud build systems, as follows
17+
you can activate features for some cloud build systems, as follows:
1818

1919
### Automatically match cloud build numbers to to your git version
2020

2121
Cloud builds tend to associate some calendar date or monotonically increasing
2222
build number to each build. These build numbers are not very informative, if at all.
2323
Instead, Nerdbank.GitVersioning can automatically set your cloud build's
24-
build number to equal the semver version calculated during your build.
24+
build number to equal the semver version calculated during your build.
2525

2626
Enable this feature by setting the `cloudBuild.buildNumber.enabled` field
2727
in your `version.json` file to `true`, as shown below:
@@ -59,6 +59,7 @@ range.
5959
| --- | --- | --- |
6060
| GitAssemblyInformationalVersion | AssemblyInformationalVersion | 1.3.1+g15e1898f47
6161
| GitBuildVersion | BuildVersion | 1.3.1.57621
62+
| GitBuildVersionSimple | BuildVersionSimple | 1.3.1
6263

6364
This means you can use these variables in subsequent steps in your cloud build
6465
such as publishing artifacts, so that your richer version information can be
@@ -76,4 +77,45 @@ in your `version.json` file to `true`, as shown below:
7677
}
7778
```
7879

80+
There are many more MSBuild variables that the build will set within the build. To make *all* these available as cloud variables (prefixed with `NBGV_`), you can set the `cloudBuild.setAllVariables` field to `true`:
81+
82+
```json
83+
{
84+
"version": "1.0",
85+
"cloudBuild": {
86+
"setVersionVariables": true,
87+
"setAllVariables": true
88+
}
89+
}
90+
```
91+
92+
Setting both of these fields to `true` means that a few variables will be defined in the cloud build server twice -- one set with the names in the table above and the other (full) set using the `NBGV_` prefix.
93+
94+
### Set cloud build variables from just one project
95+
96+
While each individual MSBuild project has its own version computed, the versions across projects are usually the same so long as you have one `version.json` file at the root of your repo. If you choose to enable setting of cloud build variables in that root version.json file, each project that builds will take a turn setting those cloud build variables. This is perhaps more work than is necessary, and when some projects compute versions differently it can lead to inconsistently defined cloud build variables, based on non-deterministic build ordering of your projects.
97+
98+
You can reduce log message noise and control for non-deterministic cloud build variables by *not* setting any of the `cloudBuild` options in your root version.json file, and instead defining an additional `version.json` file inside just *one* project directory that inherits from the base one, like this:
99+
100+
```json
101+
{
102+
"inherit": true,
103+
"cloudBuild": {
104+
"buildNumber": {
105+
"enabled": true
106+
},
107+
"setVersionVariables": true,
108+
"setAllVariables": true
109+
}
110+
}
111+
```
112+
113+
## CI Server specific configurations
114+
115+
### TeamCity
116+
TeamCity does not expose the build branch by default as an environment variable. This can be exposed by
117+
adding an environment variable with the value of `%teamcity.build.vcs.branch.<vcsid>%` where `<vcsid>` is
118+
the root id described on the TeamCity VCS roots page. Details on this variable can be found on the
119+
[TeamCity docs](https://confluence.jetbrains.com/display/TCD8/Predefined+Build+Parameters).
120+
79121
[Issue37]: https://github.com/AArnott/Nerdbank.GitVersioning/issues/37

doc/dotnet-cli.md

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
1-
# DNX or dotnet CLI
1+
# dotnet CLI
22

3-
Sorry. DNX and dotnet CLI don't support extensible versioning systems.
3+
The dotnet CLI works very much like [full MSBuild](msbuild.md). Just use `dotnet build` instead of `msbuild.exe`.
44

5-
Related issues:
6-
7-
* [DNX#3178](https://github.com/aspnet/dnx/issues/3178)
8-
* [dotnet-CLI#551](https://github.com/dotnet/cli/issues/551)
5+
[DNX never supported extensible versioning systems](https://github.com/aspnet/dnx/issues/3178). But DNX is dead now, so you probably don't care.

doc/nuget-acquisition.md

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,19 @@ Install the Nerdbank.GitVersioning package using the Visual Studio
44
NuGet Package Manager GUI, or the NuGet Package Manager Console:
55

66
```
7-
Install-Package Nerdbank-GitVersioning
7+
Install-Package Nerdbank.GitVersioning
88
```
99

10+
If in a project that uses PackageReference for this package reference, you should manually add
11+
`PrivateAssets="all"` to the PackageReference xml element to workaround
12+
[this issue](https://github.com/AArnott/Nerdbank.GitVersioning/issues/122).
13+
1014
After installing this NuGet package, you may need to configure the version generation logic
1115
in order for it to work properly.
1216

13-
With NuGet 2.x, the configuration is handled automatically via the tools\Install.ps1 script.
14-
For NuGet 3.x, you can run the script tools\Create-VersionFile.ps1 to help you create the
15-
version.json file and remove the old assembly attributes.
17+
When using packages.config, the configuration is handled automatically via the tools\Install.ps1 script.
18+
When using project.json or PackageReference, you can run the script tools\Create-VersionFile.ps1 to help
19+
you create the version.json file and remove the old assembly attributes.
1620

1721
The scripts will look for the presence of a version.json or version.txt file.
1822
If one already exists, nothing happens. If the version file does not exist,
@@ -35,14 +39,19 @@ source code, as commonly found in your `Properties\AssemblyInfo.cs` file:
3539
[assembly: AssemblyInformationalVersion("1.0.0-dev")]
3640
```
3741

42+
If you are using the new VS 2017 .NET Core/Standard projects (or otherwise using the .NET SDK project type)
43+
you won't see these attributes in your AssemblyInfo.cs file but you may still get compiler errors
44+
due to duplicate attributes. In that case, a Rebuild of your project should resolve
45+
[the issue](https://github.com/AArnott/Nerdbank.GitVersioning/issues/121).
46+
3847
This NuGet package creates these attributes at build time based on version information
3948
found in your `version.json` file and your git repo's HEAD position.
4049

4150
When the package is installed, a version.json file is created in your project directory
42-
(for NuGet 2.x clients). This ensures backwards compatibility where the installation of
51+
(for packages.config clients). This ensures backwards compatibility where the installation of
4352
this package will not cause the assembly version of the project to change. If you would
4453
like the same version number to be applied to all projects in the repo, then you may move
45-
the file to the root directory of your git repo.
54+
the version.json file to the root directory of your git repo.
4655

4756
Note: After first installing the package, you need to commit the version file so that
4857
it will be picked up during the build's version generation. If you build prior to committing,

doc/versionJson.md

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,26 @@ Here is the content of a sample version.json file you may start with:
1414
The `$schema` field is optional but highly encouraged as it causes most JSON editors
1515
to add auto-completion and doc tips to help you author the file.
1616

17+
Note that the capitalization of the `version.json` filename must be all lower-case
18+
when added to the git repo.
19+
1720
## File format
1821

1922
The content of the version.json file is a JSON serialized object with these properties
2023
(and more):
2124

2225
```js
2326
{
24-
"version": "x.y-prerelease", // required
27+
"version": "x.y-prerelease", // required (unless the "inherit" field is set to true and a parent version.json file sets this.)
2528
"assemblyVersion": "x.y", // optional. Use when x.y for AssemblyVersionAttribute differs from the default version property.
2629
"buildNumberOffset": "zOffset", // optional. Use when you need to add/subtract a fixed value from the computed build number.
30+
"semVer1NumericIdentifierPadding": 4, // optional. Use when your -prerelease includes numeric identifiers and need semver1 support.
31+
"nugetPackageVersion": {
32+
"semVer": 1 // optional. Set to either 1 or 2 to control how the NuGet package version string is generated. Default is 1.
33+
},
2734
"publicReleaseRefSpec": [
2835
"^refs/heads/master$", // we release out of master
29-
"^refs/tags/v\\d\\.\\d" // we also release tags starting with vN.N
36+
"^refs/tags/v\\d+\\.\\d+" // we also release tags starting with vN.N
3037
],
3138
"cloudBuild": {
3239
"setVersionVariables": true,
@@ -37,12 +44,18 @@ The content of the version.json file is a JSON serialized object with these prop
3744
"where": "buildMetadata"
3845
}
3946
}
40-
}
47+
},
48+
"inherit": false // optional. Set to true in secondary version.json files used to tweak settings for subsets of projects.
4149
}
4250
```
4351

4452
The `x` and `y` variables are for your use to specify a version that is meaningful
4553
to your customers. Consider using [semantic versioning][semver] for guidance.
54+
You may optionally supply a third integer in the version (i.e. x.y.z),
55+
in which case the git version height is specified as the fourth integer,
56+
which only appears in certain version representations.
57+
Alternatively, you can include the git version height in the -prerelease tag using
58+
syntax such as: `1.2.3-beta.{height}`
4659

4760
The optional -prerelease tag allows you to indicate that you are building prerelease software.
4861

doc/vsix.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,4 @@ the version calculated from your version.json file and git height.
88
1. Install the Nerdbank.GitVersioning NuGet package into your VSIX-generating project.
99
1. Open the `source.extension.vsixmanifest` file in a code editor
1010
and set the `PackageManifest/Metadata/Identity/@Version` attribute to this
11-
value: `|YourProjectName;GetBuildVersion|` where `YourProjectName` is
12-
obviously replaced with the actual project name (without extension) of your
13-
VSIX project.
11+
value: `|%CurrentProject%;GetBuildVersion|`

init.ps1

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<#
22
.SYNOPSIS
3-
Restores all NuGet, NPM and Typings packages necessary to build this repository.
3+
Restores all NuGet, NPM and Typings packages necessary to build this repository.
44
#>
55
[CmdletBinding(SupportsShouldProcess)]
66
Param(
@@ -18,12 +18,7 @@ try {
1818
& "$toolsPath\Restore-NuGetPackages.ps1" -Path $_ -Verbosity Quiet
1919
}
2020

21-
# Restore VS solution dependencies
22-
gci "$PSScriptRoot\src" -rec |? { $_.FullName.EndsWith('.sln') } |% {
23-
& "$toolsPath\Restore-NuGetPackages.ps1" -Path $_.FullName -Verbosity Quiet
24-
}
25-
26-
# Restore VS2017 style as well, since nuget 3.3 doesn't support it.
21+
# Restore VS2017 style to get the rest of the projects.
2722
msbuild "$PSScriptRoot\src\NerdBank.GitVersioning.Tests\NerdBank.GitVersioning.Tests.csproj" /t:restore /v:minimal /m /nologo
2823

2924
Write-Host "Restoring NPM packages..." -ForegroundColor Yellow

readme.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
[![Build status](https://ci.appveyor.com/api/projects/status/94wwito7ifg57d65/branch/master?svg=true)](https://ci.appveyor.com/project/AArnott/nerdbank-gitversioning/branch/master)
44
[![NuGet package](https://img.shields.io/nuget/v/Nerdbank.GitVersioning.svg)](https://nuget.org/packages/Nerdbank.GitVersioning)
5+
[![NuGet downloads](https://img.shields.io/nuget/dt/Nerdbank.GitVersioning.svg)](https://nuget.org/packages/Nerdbank.GitVersioning)
56
[![NPM package](https://img.shields.io/npm/v/nerdbank-gitversioning.svg)](https://www.npmjs.com/package/nerdbank-gitversioning)
67
[![Join the chat at https://gitter.im/AArnott/Nerdbank.GitVersioning](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/AArnott/Nerdbank.GitVersioning?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
78

src/.editorconfig

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# EditorConfig is awesome:http://EditorConfig.org
2+
3+
# top-most EditorConfig file
4+
root = true
5+
6+
# Don't use tabs for indentation.
7+
[*]
8+
indent_style = space
9+
# (Please don't specify an indent_size here; that has too many unintended consequences.)
10+
11+
# Code files
12+
[*.{cs,csx,vb,vbx}]
13+
indent_size = 4
14+
15+
# Xml project files
16+
[*.{csproj,vbproj,vcxproj,vcxproj.filters,proj,projitems,shproj}]
17+
indent_size = 2
18+
19+
# Xml config files
20+
[*.{props,targets,ruleset,config,nuspec,resx,vsixmanifest,vsct}]
21+
indent_size = 2
22+
23+
# JSON files
24+
[*.json]
25+
indent_size = 2
26+
27+
# Dotnet code style settings:
28+
[*.{cs,vb}]
29+
# Sort using and Import directives with System.* appearing first
30+
dotnet_sort_system_directives_first = true
31+
# Use "this." and "Me." everywhere
32+
dotnet_style_qualification_for_field = true:warning
33+
dotnet_style_qualification_for_property = true:warning
34+
dotnet_style_qualification_for_method = true:warning
35+
dotnet_style_qualification_for_event = true:warning
36+
37+
# Use language keywords instead of framework type names for type references
38+
dotnet_style_predefined_type_for_locals_parameters_members = true:suggestion
39+
dotnet_style_predefined_type_for_member_access = true:suggestion
40+
41+
# Suggest more modern language features when available
42+
dotnet_style_object_initializer = true:suggestion
43+
dotnet_style_collection_initializer = true:suggestion
44+
dotnet_style_coalesce_expression = true:suggestion
45+
dotnet_style_null_propagation = true:suggestion
46+
dotnet_style_explicit_tuple_names = true:suggestion
47+
48+
# CSharp code style settings:
49+
[*.cs]
50+
# Prefer "var" everywhere
51+
csharp_style_var_for_built_in_types = false:none
52+
csharp_style_var_when_type_is_apparent = true:none
53+
csharp_style_var_elsewhere = false:none
54+
55+
# Prefer method-like constructs to have a block body
56+
csharp_style_expression_bodied_methods = true:suggestion
57+
csharp_style_expression_bodied_constructors = true:suggestion
58+
csharp_style_expression_bodied_operators = true:suggestion
59+
60+
# Prefer property-like constructs to have an expression-body
61+
csharp_style_expression_bodied_properties = true:suggestion
62+
csharp_style_expression_bodied_indexers = true:suggestion
63+
csharp_style_expression_bodied_accessors = true:suggestion
64+
65+
# Suggest more modern language features when available
66+
csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion
67+
csharp_style_pattern_matching_over_as_with_null_check = true:suggestion
68+
csharp_style_inlined_variable_declaration = true:suggestion
69+
csharp_style_throw_expression = true:suggestion
70+
csharp_style_conditional_delegate_call = true:suggestion
71+
72+
# Newline settings
73+
csharp_new_line_before_open_brace = all
74+
csharp_new_line_before_else = true
75+
csharp_new_line_before_catch = true
76+
csharp_new_line_before_finally = true
77+
csharp_new_line_before_members_in_object_initializers = true
78+
csharp_new_line_before_members_in_anonymous_types = true

0 commit comments

Comments
 (0)