Skip to content

Commit 3b61d1a

Browse files
authored
Merge pull request #111 from AArnott/dotnetCore
Add support for MSBuild Core (aka `dotnet build`)
2 parents b635538 + 8b60fcb commit 3b61d1a

38 files changed

+457
-416
lines changed

CONTRIBUTING.md

Lines changed: 5 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ This project is actively developed using the following software.
77
It is highly recommended that anyone contributing to this library use the same
88
software.
99

10-
1. [Visual Studio 2015][VS]
10+
1. [Visual Studio 2017][VS]
1111
2. [Node.js][NodeJs]
1212

1313
### Optional additional software
@@ -17,7 +17,6 @@ They are not required to build the full solution from the command line using MSB
1717
but installing this software will facilitate an enhanced developer experience in Visual Studio.
1818

1919
1. [Node.js Tools for Visual Studio][NodeJsTools]
20-
2. [NuProj for VS2015][NuProj]
2120

2221
All other dependencies are acquired via NuGet or NPM.
2322

@@ -30,8 +29,8 @@ and you are running Windows PowerShell, the command is:
3029

3130
.\init.ps1
3231

33-
Everything in the repo may be built via building the solution file
34-
either from Visual Studio 2015 or the VS2015 Developer Command Prompt:
32+
Most of the repo may be built via building the solution file from Visual Studio 2017,
33+
but for a complete build, build from the VS2017 Developer Command Prompt:
3534

3635
.\build.ps1
3736

@@ -40,28 +39,9 @@ It then builds an NPM package that includes some of the outputs of MSBuild, alon
4039
some javascript, for our NPM consumers who want a reasonable versioning story for their
4140
NPM packages too.
4241

43-
### Important notice when developing with Visual Studio
44-
45-
The NuGet package restore functionality in Visual Studio does not work for this project, which relies
46-
on newer functionality than comes with Visual Studio 2015 Update 3. You should disable automatic
47-
package restore on build in Visual Studio in order to build successfully and have a useful Error List
48-
while developing.
49-
50-
Follow these steps to disable automatic package restore in Visual Studio:
51-
52-
1. Tools -> Options -> NuGet Package Manager -> General
53-
2. *Clear* the checkbox for "Automatically check for missing packages during build in Visual Studio
54-
55-
With this setting, you can still execute a package restore within Visual Studio by right-clicking
56-
on the _solution_ node in Solution Explorer and clicking "Restore NuGet Packages". But do not ever
57-
execute that on this project as that will corrupt the result of `init.ps1`.
58-
59-
Before developing this project in Visual Studio, or after making project or project.json changes,
60-
or to recover after Visual Studio executes a package restore, run the `init` script again.
61-
6242
## Testing
6343

64-
The Visual Studio 2015 Test Explorer will list and execute all tests.
44+
The Visual Studio 2017 Test Explorer will list and execute all tests.
6545

6646
## Pull requests
6747

@@ -104,8 +84,6 @@ for your pull request. You can get the version number by reviewing the result of
10484
validation build for your pull request, clicking ARTIFACTS, and noting the version
10585
of the produced packages.
10686

107-
[VS]: https://www.visualstudio.com/en-us/downloads/visual-studio-2015-downloads-vs.aspx
87+
[VS]: https://www.visualstudio.com/downloads/
10888
[NodeJs]: https://nodejs.org
109-
[NuProj]: https://onedrive.live.com/redir?resid=63D0C265F96E43D!2477835&authkey=!AHh2k9FoNR-nFHo&ithint=file%2cmsi
11089
[NodeJsTools]: https://www.visualstudio.com/vs/node-js/
111-
[NuGetClient]: https://dist.nuget.org/win-x86-commandline/v3.3.0/nuget.exe

appveyor.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
11
version: 1.0.{build}
22
skip_tags: true
3-
os: Visual Studio 2015
3+
os: Visual Studio 2017 RC
44
configuration: Release
55
cache:
6-
- '%USERPROFILE%\.nuget\packages -> **\project.json'
76
- '%APPDATA%\npm-cache -> src\nerdbank-gitversioning.npm\package.json'
87
init:
98
- ps: >-
109
git config --global user.name appveyor
1110
1211
git config --global user.email [email protected]
1312
environment:
14-
VisualStudioVersion: 14.0
13+
VisualStudioVersion: 15.0
1514
install:
1615
- ps: >-
1716
npm install npm -g
@@ -21,7 +20,8 @@ before_build:
2120
2221
#$blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1'))
2322
build_script:
24-
- ps: .\build.ps1
23+
- ps: >-
24+
.\build.ps1
2525
artifacts:
2626
- path: bin\**\*.nupkg
2727
- path: bin\js\*.tgz

init.ps1

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ try {
2323
& "$toolsPath\Restore-NuGetPackages.ps1" -Path $_.FullName -Verbosity Quiet
2424
}
2525

26+
# Restore VS2017 style as well, since nuget 3.3 doesn't support it.
27+
msbuild "$PSScriptRoot\src\NerdBank.GitVersioning.Tests\NerdBank.GitVersioning.Tests.csproj" /t:restore /v:minimal /m /nologo
28+
2629
Write-Host "Restoring NPM packages..." -ForegroundColor Yellow
2730
Push-Location "$PSScriptRoot\src\nerdbank-gitversioning.npm"
2831
try {

src/Directory.Build.props

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<Project>
2+
<PropertyGroup>
3+
<BaseIntermediateOutputPath>$(MSBuildThisFileDirectory)..\obj\$(MSBuildProjectName)\</BaseIntermediateOutputPath>
4+
<OutputPath>$(MSBuildThisFileDirectory)..\bin\$(MSBuildProjectName)\$(Configuration)\</OutputPath>
5+
</PropertyGroup>
6+
</Project>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<configuration>
3+
<runtime>
4+
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
5+
<dependentAssembly>
6+
<assemblyIdentity name="Validation" publicKeyToken="2fc06f0d701809a7" culture="neutral" />
7+
<bindingRedirect oldVersion="2.0.0.0" newVersion="2.3.0.0" />
8+
</dependentAssembly>
9+
</assemblyBinding>
10+
</runtime>
11+
</configuration>

src/NerdBank.GitVersioning.Tests/BuildIntegrationTests.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public BuildIntegrationTests(ITestOutputHelper logger)
5757
this.projectDirectory = Path.Combine(this.RepoPath, "projdir");
5858
Directory.CreateDirectory(this.projectDirectory);
5959
this.LoadTargetsIntoProjectCollection();
60-
this.testProject = this.CreateProjectRootElement(this.projectDirectory, "test.proj");
60+
this.testProject = this.CreateProjectRootElement(this.projectDirectory, "test.prj");
6161
this.globalProperties.Add("NerdbankGitVersioningTasksPath", Environment.CurrentDirectory + "\\");
6262
Environment.SetEnvironmentVariable("_NBGV_UnitTest", "true");
6363

@@ -582,7 +582,7 @@ public async Task PublicRelease_RegEx_SatisfiedByCheckedOutBranch()
582582
{
583583
// Check out a branch that conforms.
584584
var releaseBranch = this.Repo.CreateBranch("release");
585-
this.Repo.Checkout(releaseBranch);
585+
Commands.Checkout(this.Repo, releaseBranch);
586586
var buildResult = await this.BuildAsync();
587587
Assert.True(buildResult.PublicRelease);
588588
AssertStandardProperties(versionOptions, buildResult);
@@ -888,7 +888,7 @@ private async Task<BuildResults> BuildAsync(string target = Targets.GetBuildVers
888888

889889
private void LoadTargetsIntoProjectCollection()
890890
{
891-
const string prefix = "Nerdbank.GitVersioning.Tests.Targets.";
891+
string prefix = $"{ThisAssembly.RootNamespace}.Targets.";
892892

893893
var streamNames = from name in Assembly.GetExecutingAssembly().GetManifestResourceNames()
894894
where name.StartsWith(prefix, StringComparison.Ordinal)
@@ -905,7 +905,7 @@ where name.StartsWith(prefix, StringComparison.Ordinal)
905905

906906
private ProjectRootElement CreateProjectRootElement(string projectDirectory, string projectName)
907907
{
908-
using (var reader = XmlReader.Create(Assembly.GetExecutingAssembly().GetManifestResourceStream($"{ThisAssembly.RootNamespace}.test.proj")))
908+
using (var reader = XmlReader.Create(Assembly.GetExecutingAssembly().GetManifestResourceStream($"{ThisAssembly.RootNamespace}.test.prj")))
909909
{
910910
var pre = ProjectRootElement.Create(reader, this.projectCollection);
911911
pre.FullPath = Path.Combine(projectDirectory, projectName);

src/NerdBank.GitVersioning.Tests/GitExtensionsTests.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public void GetHeight_Merge()
4747
var firstCommit = this.Repo.Commit("First", this.Signer, this.Signer, new CommitOptions { AllowEmptyCommit = true });
4848
var anotherBranch = this.Repo.CreateBranch("another");
4949
var secondCommit = this.Repo.Commit("Second", this.Signer, this.Signer, new CommitOptions { AllowEmptyCommit = true });
50-
this.Repo.Checkout(anotherBranch);
50+
Commands.Checkout(this.Repo, anotherBranch);
5151
Commit[] branchCommits = new Commit[5];
5252
for (int i = 1; i <= branchCommits.Length; i++)
5353
{
@@ -83,7 +83,7 @@ public void GetVersionHeight_VersionJsonHasUnrelatedHistory()
8383
string versionJsonPath = Path.Combine(this.RepoPath, "version.json");
8484
File.WriteAllText(versionJsonPath, @"{ ""unrelated"": false }");
8585
Assert.Equal(0, this.Repo.GetVersionHeight()); // exercise code that handles the file not yet checked in.
86-
this.Repo.Stage(versionJsonPath);
86+
Commands.Stage(this.Repo, versionJsonPath);
8787
this.Repo.Commit("Add unrelated version.json file.", this.Signer, this.Signer);
8888
Assert.Equal(1, this.Repo.GetVersionHeight()); // exercise code that handles a checked in file.
8989

@@ -109,7 +109,7 @@ public void GetVersionHeight_VersionJsonHasParsingErrorsInHistory()
109109
string versionJsonPath = Path.Combine(this.RepoPath, "version.json");
110110
File.WriteAllText(versionJsonPath, @"{ ""version"": ""1.0"""); // no closing curly brace for parsing error
111111
Assert.Equal(0, this.Repo.GetVersionHeight());
112-
this.Repo.Stage(versionJsonPath);
112+
Commands.Stage(this.Repo, versionJsonPath);
113113
this.Repo.Commit("Add broken version.json file.", this.Signer, this.Signer);
114114
Assert.Equal(1, this.Repo.GetVersionHeight());
115115

Lines changed: 16 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -1,96 +1,29 @@
1-
<?xml version="1.0" encoding="utf-8"?>
2-
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3-
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
1+
<Project Sdk="Microsoft.NET.Sdk">
42
<PropertyGroup>
5-
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6-
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7-
<ProjectGuid>{C54F9EC8-FDA7-4D22-BCB2-7D97523BD91E}</ProjectGuid>
8-
<OutputType>Library</OutputType>
9-
<AppDesignerFolder>Properties</AppDesignerFolder>
10-
<RootNamespace>Nerdbank.GitVersioning.Tests</RootNamespace>
11-
<AssemblyName>NerdBank.GitVersioning.Tests</AssemblyName>
12-
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
13-
<FileAlignment>512</FileAlignment>
14-
<NuGetPackageImportStamp>
15-
</NuGetPackageImportStamp>
16-
<CopyNugetImplementations>true</CopyNugetImplementations>
3+
<TargetFramework>net45</TargetFramework>
174
</PropertyGroup>
18-
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
19-
<DebugSymbols>true</DebugSymbols>
20-
<DebugType>full</DebugType>
21-
<Optimize>false</Optimize>
22-
<OutputPath>bin\Debug\</OutputPath>
23-
<DefineConstants>DEBUG;TRACE</DefineConstants>
24-
<ErrorReport>prompt</ErrorReport>
25-
<WarningLevel>4</WarningLevel>
26-
</PropertyGroup>
27-
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
28-
<DebugType>pdbonly</DebugType>
29-
<Optimize>true</Optimize>
30-
<OutputPath>bin\Release\</OutputPath>
31-
<DefineConstants>TRACE</DefineConstants>
32-
<ErrorReport>prompt</ErrorReport>
33-
<WarningLevel>4</WarningLevel>
34-
</PropertyGroup>
35-
<ItemGroup>
36-
<Reference Include="Microsoft.Build" />
37-
<Reference Include="Microsoft.Build.Framework" />
38-
<Reference Include="Microsoft.Build.Tasks.v4.0" />
39-
<Reference Include="System" />
40-
<Reference Include="System.Core" />
41-
<Reference Include="System.Xml.Linq" />
42-
<Reference Include="System.Data.DataSetExtensions" />
43-
<Reference Include="Microsoft.CSharp" />
44-
<Reference Include="System.Data" />
45-
<Reference Include="System.Net.Http" />
46-
<Reference Include="System.Xml" />
47-
</ItemGroup>
48-
<ItemGroup>
49-
<Compile Include="BuildIntegrationTests.cs" />
50-
<Compile Include="GitExtensionsTests.cs" />
51-
<Compile Include="MSBuildExtensions.cs" />
52-
<Compile Include="Properties\AssemblyInfo.cs" />
53-
<Compile Include="RepoTestBase.cs" />
54-
<Compile Include="SemanticVersionTests.cs" />
55-
<Compile Include="TestUtilities.cs" />
56-
<Compile Include="VersionExtensionsTests.cs" />
57-
<Compile Include="VersionFileTests.cs" />
58-
<Compile Include="VersionOptionsTests.cs" />
59-
<Compile Include="VersionOracleTests.cs" />
60-
</ItemGroup>
615
<ItemGroup>
626
<EmbeddedResource Include="..\Nerdbank.GitVersioning.NuGet\build\*.targets">
637
<Visible>false</Visible>
648
<Link>Targets\%(FileName)%(Extension)</Link>
659
</EmbeddedResource>
66-
<EmbeddedResource Include="Keys\keypair.snk" />
67-
<EmbeddedResource Include="Keys\public.snk" />
68-
</ItemGroup>
69-
<ItemGroup>
70-
<ProjectReference Include="..\NerdBank.GitVersioning.Tasks\Nerdbank.GitVersioning.Tasks.csproj">
71-
<Project>{d76be1f9-5063-4443-b792-eaeecaa457d7}</Project>
72-
<Name>Nerdbank.GitVersioning.Tasks</Name>
73-
</ProjectReference>
74-
<ProjectReference Include="..\NerdBank.GitVersioning\NerdBank.GitVersioning.csproj">
75-
<Project>{50d7b410-d986-499a-9fd1-fbbb55b095bd}</Project>
76-
<Name>NerdBank.GitVersioning</Name>
77-
</ProjectReference>
10+
<EmbeddedResource Include="Keys\*.snk" />
11+
<EmbeddedResource Include="Keys\*.pfx" />
12+
<EmbeddedResource Include="test.prj" />
13+
<EmbeddedResource Include="repos\submodules.7z" />
7814
</ItemGroup>
7915
<ItemGroup>
80-
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
16+
<ProjectReference Include="..\Nerdbank.GitVersioning.Tasks\Nerdbank.GitVersioning.Tasks.csproj" />
17+
<ProjectReference Include="..\NerdBank.GitVersioning\NerdBank.GitVersioning.csproj" />
8118
</ItemGroup>
8219
<ItemGroup>
83-
<EmbeddedResource Include="Keys\protectedPair.pfx" />
84-
<None Include="project.json" />
85-
<EmbeddedResource Include="test.proj" />
86-
<EmbeddedResource Include="repos\submodules.7z" />
20+
<PackageReference Include="7z.NET" Version="1.0.3" />
21+
<PackageReference Include="System.Collections.Immutable" Version="1.3.1" />
22+
<PackageReference Include="Microsoft.Build" Version="14.3" Condition=" '$(TargetFramework)' == 'net45' " />
23+
<PackageReference Include="Xunit.Combinatorial" Version="1.1.12" />
24+
<PackageReference Include="xunit" Version="2.1.0" />
25+
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="1.1.1" />
26+
<PackageReference Include="Nerdbank.GitVersioning.LKG" Version="1.5.108-g37118a0bd6" />
27+
<PackageReference Include="xunit.runner.visualstudio" Version="2.1.0" />
8728
</ItemGroup>
88-
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
89-
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
90-
Other similar extension points exist, see Microsoft.Common.targets.
91-
<Target Name="BeforeBuild">
92-
</Target>
93-
<Target Name="AfterBuild">
94-
</Target>
95-
-->
9629
</Project>

src/NerdBank.GitVersioning.Tests/Properties/AssemblyInfo.cs

Lines changed: 0 additions & 20 deletions
This file was deleted.

src/NerdBank.GitVersioning.Tests/RepoTestBase.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ protected void InitializeSourceControl()
6161
this.Repo = new Repository(this.RepoPath);
6262
foreach (var file in this.Repo.RetrieveStatus().Untracked)
6363
{
64-
this.Repo.Stage(file.FilePath);
64+
Commands.Stage(this.Repo, file.FilePath);
6565
}
6666

6767
if (this.Repo.Index.Count > 0)

0 commit comments

Comments
 (0)