diff --git a/.gitignore b/.gitignore index 3b869cb610..96a6f29cb9 100644 --- a/.gitignore +++ b/.gitignore @@ -110,8 +110,10 @@ src/GitVersionTfsTask/*.js #################### # Cake #################### -/tools +tools/* +!tools/packages.config /*.zip GitVersion.CommandLine/*/ -releaseArtifacts \ No newline at end of file +releaseArtifacts +/ILMergeTemp diff --git a/.travis.yml b/.travis.yml index 2f95b12cf3..5259e80a37 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,15 +1,17 @@ language: csharp -sudo: false +sudo: required +dist: trusty +dotnet: 2.1.105 mono: - latest os: - linux - osx before_install: - - git fetch --unshallow # Travis always does a shallow clone, but GitVersion needs the full history including branches and tags + - git fetch --unshallow # Travis always does a shallow clone, but GitVersion needs the full history including branches and tags script: - - ./build.sh -cache: - directories: - - src/packages - - tools + - ./build.sh -v Diagnostic +env: + global: + - DOTNET_CLI_TELEMETRY_OPTOUT: 1 + - DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true \ No newline at end of file diff --git a/appveyor.yml b/appveyor.yml index d25bd9bb1f..6df9d5c357 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,3 +1,4 @@ +image: Visual Studio 2017 install: npm i -g tfx-cli diff --git a/build.cake b/build.cake index 2c26a2a751..10930a0e24 100644 --- a/build.cake +++ b/build.cake @@ -1,5 +1,7 @@ #tool "nuget:https://www.nuget.org/api/v2?package=NUnit.ConsoleRunner&version=3.7.0" #tool "nuget:https://www.nuget.org/api/v2?package=GitReleaseNotes&version=0.7.0" +#tool "nuget:https://www.nuget.org/api/v2?package=ILRepack&version=2.0.15" +#addin "nuget:?package=Cake.Incubator" var target = Argument("target", "Default"); var configuration = Argument("configuration", "Release"); @@ -16,39 +18,45 @@ bool IsMainGitVersionRepo = StringComparer.OrdinalIgnoreCase.Equals("gittools/gi bool IsPullRequest = BuildSystem.AppVeyor.Environment.PullRequest.IsPullRequest; bool IsMainGitVersionBranch = StringComparer.OrdinalIgnoreCase.Equals("master", BuildSystem.AppVeyor.Environment.Repository.Branch); +string buildDir = "./build/"; + void Build(string configuration, string nugetVersion, string semVersion, string version, string preReleaseTag) { - if(IsRunningOnUnix()) - { - XBuild("./src/GitVersion.sln", new XBuildSettings() - .SetConfiguration(configuration) - .WithProperty("POSIX", "True") - .SetVerbosity(Verbosity.Minimal)); - } - else - { - var msBuildSettings = new MSBuildSettings() - .SetConfiguration(configuration) - .SetPlatformTarget(PlatformTarget.MSIL) - .WithProperty("Windows", "True") - .UseToolVersion(MSBuildToolVersion.VS2015) - .SetVerbosity(Verbosity.Minimal) - .SetNodeReuse(false); - - if (BuildSystem.AppVeyor.IsRunningOnAppVeyor) - { - msBuildSettings = msBuildSettings - .WithProperty("GitVersion_NuGetVersion", nugetVersion) - .WithProperty("GitVersion_SemVer", semVersion) - .WithProperty("GitVersion_MajorMinorPatch", version) - .WithProperty("GitVersion_PreReleaseTag", preReleaseTag); - } - MSBuild("./src/GitVersion.sln", msBuildSettings); - } + + MSBuild("./src/GitVersion.sln", settings => + { + settings.SetConfiguration(configuration) + .SetVerbosity(Verbosity.Minimal) + .WithTarget("Build") + .WithProperty("POSIX",IsRunningOnUnix().ToString()); + + if (BuildSystem.AppVeyor.IsRunningOnAppVeyor) + { + if (!string.IsNullOrWhiteSpace(nugetVersion)) + { + settings.WithProperty("GitVersion_NuGetVersion", nugetVersion); + } + if (!string.IsNullOrWhiteSpace(semVersion)) + { + settings.WithProperty("GitVersion_SemVer", semVersion); + } + + if (!string.IsNullOrWhiteSpace(version)) + { + settings.WithProperty("GitVersion_MajorMinorPatch", version); + } + + if (!string.IsNullOrWhiteSpace(preReleaseTag)) + { + settings.WithProperty("GitVersion_PreReleaseTag", preReleaseTag); + } + } + }); } // This build task can be run to just build Task("DogfoodBuild") + .IsDependentOn("Clean") .IsDependentOn("NuGet-Package-Restore") .Does(() => { @@ -64,12 +72,12 @@ Task("Version") UpdateAssemblyInfo = true, LogFilePath = "console", OutputType = GitVersionOutput.BuildServer, - ToolPath = @"src\GitVersionExe\bin\Release\GitVersion.exe" + ToolPath = @"src\GitVersionExe\bin\Release\net40\GitVersion.exe" }); GitVersion assertedVersions = GitVersion(new GitVersionSettings { OutputType = GitVersionOutput.Json, - ToolPath = @"src\GitVersionExe\bin\Release\GitVersion.exe" + ToolPath = @"src\GitVersionExe\bin\Release\net40\GitVersion.exe" }); version = assertedVersions.MajorMinorPatch; @@ -81,10 +89,22 @@ Task("Version") Task("NuGet-Package-Restore") .Does(() => { - NuGetRestore("./src/GitVersion.sln"); + DotNetCoreRestore("./src/GitVersion.sln"); + //NuGetRestore("./src/GitVersion.sln"); +}); + +Task("Clean") + .Does(() => +{ + CleanDirectories("./build"); + CleanDirectories("./**/obj"); + + var binDirs = GetDirectories("./**/bin") - GetDirectories("**/GemAssets/bin"); + CleanDirectories(binDirs); }); Task("Build") + .IsDependentOn("Clean") .IsDependentOn("Version") .IsDependentOn("NuGet-Package-Restore") .Does(() => @@ -92,19 +112,21 @@ Task("Build") Build(configuration, nugetVersion, semVersion, version, preReleaseTag); }); -Task("Run-NUnit-Tests") +Task("Run-Tests-In-NUnitConsole") .IsDependentOn("DogfoodBuild") .Does(() => { var settings = new NUnit3Settings(); + var targetFramework = "net461"; if(IsRunningOnUnix()) { settings.Where = "cat != NoMono"; } + NUnit3(new [] { - "src/GitVersionCore.Tests/bin/" + configuration + "/GitVersionCore.Tests.dll", - "src/GitVersionExe.Tests/bin/" + configuration + "/GitVersionExe.Tests.dll", - "src/GitVersionTask.Tests/bin/" + configuration + "/GitVersionTask.Tests.dll" }, + "src/GitVersionCore.Tests/bin/" + configuration + "/" + targetFramework + "/GitVersionCore.Tests.dll", + "src/GitVersionExe.Tests/bin/" + configuration + "/" + targetFramework + "/GitVersionExe.Tests.dll", + "src/GitVersionTask.Tests/bin/" + configuration + "/" + targetFramework + "/GitVersionTask.Tests.dll" }, settings); if (AppVeyor.IsRunningOnAppVeyor) { @@ -113,14 +135,263 @@ Task("Run-NUnit-Tests") } }); +// Note: this task is not used for time being as unable to produce sensible test results output file via dotnet cli.. so using nunit console runner above instead. +Task("Run-Tests") + .IsDependentOn("DogfoodBuild") + .Does(() => +{ + var settings = new DotNetCoreTestSettings + { + Configuration = configuration, + NoBuild = true, + Filter = "TestCategory!=NoMono" + }; + + DotNetCoreTest("./src/GitVersionCore.Tests/GitVersionCore.Tests.csproj", settings); + DotNetCoreTest("./src/GitVersionExe.Tests/GitVersionExe.Tests.csproj", settings); + DotNetCoreTest("./src/GitVersionTask.Tests/GitVersionTask.Tests.csproj", settings); + +}); + +void ILRepackGitVersionExe(bool includeLibGit2Sharp) +{ + var tempMergeDir = "ILMergeTemp"; + var exeName = "GitVersion.exe"; + var keyFilePath = "./src/key.snk"; + var targetDir = "./src/GitVersionExe/bin/" + configuration + "/net40/"; + var targetPath = targetDir + exeName; + + CreateDirectory(tempMergeDir); + string outFilePath = "./" + tempMergeDir + "/" + exeName; + + var sourcePattern = targetDir + "*.dll"; + var sourceFiles = GetFiles(sourcePattern); + if(!includeLibGit2Sharp) + { + var excludePattern = "**/LibGit2Sharp.dll"; + sourceFiles = sourceFiles - GetFiles(excludePattern); + } + var settings = new ILRepackSettings { AllowDup = "", Keyfile = keyFilePath, Internalize = true, NDebug = true, TargetKind = TargetKind.Exe, TargetPlatform = TargetPlatformVersion.v4, XmlDocs = false }; + ILRepack(outFilePath, targetPath, sourceFiles, settings); +} + + +Task("Commandline-Package") + .IsDependentOn("Build") + .Does(() => +{ + + ILRepackGitVersionExe(false); + + var outputDir = buildDir + "NuGetCommandLineBuild"; + var toolsDir = outputDir + "/tools"; + var libDir = toolsDir + "/lib"; + + CreateDirectory(outputDir); + CreateDirectory(toolsDir); + CreateDirectory(libDir); + + var targetDir = "./src/GitVersionExe/bin/" + configuration + "/net40/"; + + var libGitFiles = GetFiles(targetDir + "LibGit2Sharp.dll*"); + var nugetAssetsPath = "./src/GitVersionExe/NugetAssets/"; + Information("Copying files to packaging direcory.."); + + CopyFiles(targetDir + "GitVersion.pdb", outputDir + "/tools/"); + CopyFiles(targetDir + "GitVersion.exe.mdb", outputDir + "/tools/"); + + Information("Copying IL Merged exe file.."); + CopyFiles("./ILMergeTemp/GitVersion.exe", outputDir + "/tools/"); + + Information("Copying nuget assets.."); + CopyFiles(nugetAssetsPath + "GitVersion.CommandLine.nuspec", outputDir); + + Information("Copying libgit2sharp files.."); + CopyFiles(libGitFiles, outputDir + "/tools/"); + CopyDirectory(targetDir + "lib/", outputDir + "/tools/lib/"); + + Information("Creating Nuget Package.."); + var nuGetPackSettings = new NuGetPackSettings { Version = nugetVersion, BasePath = outputDir, OutputDirectory = outputDir }; + NuGetPack(outputDir + "/GitVersion.CommandLine.nuspec", nuGetPackSettings); + +}) +.ReportError(exception => +{ + Error(exception.Dump()); + // Report the error. +}); + + +Task("Portable-Package") + .IsDependentOn("Build") + .Does(() => +{ + + ILRepackGitVersionExe(true); + + var outputDir = buildDir + "NuGetExeBuild"; + var toolsDir = outputDir + "/tools"; + var libDir = toolsDir + "/lib"; + + CreateDirectory(outputDir); + CreateDirectory(toolsDir); + CreateDirectory(libDir); + + var targetDir = "./src/GitVersionExe/bin/" + configuration + "/net40/"; + + var nugetAssetsPath = "./src/GitVersionExe/NugetAssets/"; + Information("Copying files to packaging direcory.."); + + CopyFiles(targetDir + "GitVersion.pdb", outputDir + "/tools/"); + CopyFiles(targetDir + "GitVersion.exe.mdb", outputDir + "/tools/"); + + Information("Copying IL Merged exe file.."); + CopyFiles("./ILMergeTemp/GitVersion.exe", outputDir + "/tools/"); + + Information("Copying nuget assets.."); + CopyFiles(nugetAssetsPath + "*.ps1", outputDir + "/tools/"); + CopyFiles(nugetAssetsPath + "GitVersion.Portable.nuspec", outputDir); + + Information("Copying libgit2sharp files.."); + CopyDirectory(targetDir + "lib/", outputDir + "/tools/lib/"); + + var nuGetPackSettings = new NuGetPackSettings { Version = nugetVersion, BasePath = outputDir, OutputDirectory = outputDir }; + NuGetPack(outputDir + "/GitVersion.Portable.nuspec", nuGetPackSettings); + +}) +.ReportError(exception => +{ + Error(exception.Dump()); +}); + + +Task("GitVersionCore-Package") + .IsDependentOn("Build") + .Does(() => +{ + var outputDir = buildDir + "NuGetRefBuild"; + CreateDirectory(outputDir); + + var msBuildSettings = new DotNetCoreMSBuildSettings(); + msBuildSettings.SetVersion(nugetVersion); + msBuildSettings.Properties["PackageVersion"] = new string[]{ nugetVersion }; + var settings = new DotNetCorePackSettings + { + Configuration = configuration, + OutputDirectory = outputDir, + NoBuild = true, + MSBuildSettings = msBuildSettings + }; + + DotNetCorePack("./src/GitVersionCore", settings); +}) +.ReportError(exception => +{ + Error(exception.Dump()); +}); + +Task("GitVersion-DotNet-Package") + .IsDependentOn("Build") + .Does(() => +{ + + // var publishDir = buildDir + "Published"; + // CreateDirectory(outputDir); + + var outputDir = buildDir + "NuGetExeDotNetCoreBuild"; + var toolsDir = outputDir + "/tools"; + var libDir = toolsDir + "/lib"; + + CreateDirectory(outputDir); + CreateDirectory(toolsDir); + CreateDirectory(libDir); + + + var msBuildSettings = new DotNetCoreMSBuildSettings(); + msBuildSettings.SetVersion(nugetVersion); + msBuildSettings.Properties["PackageVersion"] = new string[]{ nugetVersion }; + + var framework = "netcoreapp20"; + + var settings = new DotNetCorePublishSettings + { + Framework = framework, + Configuration = configuration, + OutputDirectory = toolsDir, + MSBuildSettings = msBuildSettings + }; + + DotNetCorePublish("./src/GitVersionExe", settings); + + + + // var targetDir = "./src/GitVersionExe/bin/" + configuration + "/" + framework + "/"; + + var nugetAssetsPath = "./src/GitVersionExe/NugetAssets/"; + Information("Copying files to packaging direcory.."); + + Information("Copying nuget assets.."); + CopyFiles(nugetAssetsPath + "GitVersion.CommandLine.DotNetCore.nuspec", outputDir); + + //Information("Copying libgit2sharp files.."); + //CopyDirectory(targetDir + "lib/", outputDir + "/tools/lib/"); + + var nuGetPackSettings = new NuGetPackSettings { Version = nugetVersion, BasePath = outputDir, OutputDirectory = outputDir }; + NuGetPack(outputDir + "/GitVersion.CommandLine.DotNetCore.nuspec", nuGetPackSettings); +}) +.ReportError(exception => +{ + Error(exception.Dump()); +}); + + +Task("GitVersionTaskPackage") + .Description("Produces the nuget package for GitVersionTask") + .Does(() => +{ + + var outputDir = buildDir + "NuGetTaskBuild"; + CreateDirectory(outputDir); + + var msBuildSettings = new DotNetCoreMSBuildSettings(); + msBuildSettings.SetVersion(nugetVersion); + + msBuildSettings.Properties["PackageVersion"] = new string[]{ nugetVersion }; + var settings = new DotNetCorePackSettings + { + Configuration = configuration, + OutputDirectory = outputDir, + NoBuild = true, + MSBuildSettings = msBuildSettings + }; + + DotNetCorePack("./src/GitVersionTask", settings); + +}) +.ReportError(exception => +{ + Error(exception.Dump()); +}); + Task("Zip-Files") .IsDependentOn("Build") - .IsDependentOn("Run-NUnit-Tests") + .IsDependentOn("Commandline-Package") + .IsDependentOn("Portable-Package") + .IsDependentOn("GitVersionCore-Package") + .IsDependentOn("GitVersionTaskPackage") + .IsDependentOn("GitVersion-DotNet-Package") + .IsDependentOn("Run-Tests-In-NUnitConsole") .Does(() => { - Zip("./build/NuGetCommandLineBuild/Tools/", "build/GitVersion_" + nugetVersion + ".zip"); + Zip("./build/NuGetCommandLineBuild/tools/", "build/GitVersion_" + nugetVersion + ".zip"); + Zip("./build/NuGetExeDotNetCoreBuild/tools/", "build/GitVersionDotNetCore_" + nugetVersion + ".zip"); +}) +.ReportError(exception => +{ + Error(exception.Dump()); }); + Task("Create-Release-Notes") .IsDependentOn("Build") .WithCriteria(() => IsMainGitVersionRepo && IsMainGitVersionBranch && !IsPullRequest) @@ -148,8 +419,13 @@ Task("Create-Release-Notes") { Information("Create-Release-Notes is being skipped, as GitHub Token is not present."); } +}) +.ReportError(exception => +{ + Error(exception.Dump()); }); + Task("Package") .IsDependentOn("Create-Release-Notes") .IsDependentOn("Zip-Files"); @@ -166,20 +442,24 @@ Task("Upload-AppVeyor-Artifacts") System.IO.File.WriteAllLines("build/artifacts", new[]{ "NuGetExeBuild:GitVersion.Portable." + nugetVersion +".nupkg", "NuGetCommandLineBuild:GitVersion.CommandLine." + nugetVersion +".nupkg", + "NuGetExeDotNetCoreBuild:GitVersion.CommandLine.DotNetCore." + nugetVersion +".nupkg", "NuGetRefBuild:GitVersion." + nugetVersion +".nupkg", - "NuGetTaskBuild:GitVersionTask." + nugetVersion +".nupkg", - "GitVersionTfsTaskBuild:gittools.gitversion-" + semVersion +".vsix", - "GemBuild:" + gem, - "zip:GitVersion_" + nugetVersion + ".zip" + "NuGetTaskBuild:GitVersionTask." + nugetVersion +".nupkg", + "zip:GitVersion_" + nugetVersion + ".zip", + "zip-dotnetcore:GitVersionDotNetCore_" + nugetVersion + ".zip" + // "GitVersionTfsTaskBuild:gittools.gitversion-" + semVersion +".vsix", + // "GemBuild:" + gem }); AppVeyor.UploadArtifact("build/NuGetExeBuild/GitVersion.Portable." + nugetVersion +".nupkg"); AppVeyor.UploadArtifact("build/NuGetCommandLineBuild/GitVersion.CommandLine." + nugetVersion +".nupkg"); - AppVeyor.UploadArtifact("build/NuGetRefBuild/GitVersion." + nugetVersion +".nupkg"); - AppVeyor.UploadArtifact("build/NuGetTaskBuild/GitVersionTask." + nugetVersion +".nupkg"); - AppVeyor.UploadArtifact("build/GitVersionTfsTaskBuild/gittools.gitversion-" + semVersion + ".vsix"); + AppVeyor.UploadArtifact("build/NuGetExeDotNetCoreBuild/GitVersion.CommandLine.DotNetCore." + nugetVersion +".nupkg"); + AppVeyor.UploadArtifact("build/NuGetRefBuild/GitVersionCore." + nugetVersion +".nupkg"); + AppVeyor.UploadArtifact("build/NuGetTaskBuild/GitVersionTask." + nugetVersion +".nupkg"); AppVeyor.UploadArtifact("build/GitVersion_" + nugetVersion + ".zip"); - AppVeyor.UploadArtifact("build/GemBuild/" + gem); + AppVeyor.UploadArtifact("build/GitVersionDotNetCore_" + nugetVersion + ".zip"); + // AppVeyor.UploadArtifact("build/GitVersionTfsTaskBuild/gittools.gitversion-" + semVersion + ".vsix"); + // AppVeyor.UploadArtifact("build/GemBuild/" + gem); AppVeyor.UploadArtifact("build/artifacts"); if(IsMainGitVersionRepo && IsMainGitVersionBranch && !IsPullRequest) @@ -189,11 +469,14 @@ Task("Upload-AppVeyor-Artifacts") AppVeyor.UploadArtifact("build/releasenotes.md"); } } +}) +.ReportError(exception => +{ + Error(exception.Dump()); }); - Task("Travis") - .IsDependentOn("Run-NUnit-Tests"); + .IsDependentOn("Run-Tests"); Task("Default") .IsDependentOn("Upload-AppVeyor-Artifacts"); diff --git a/deploy.cake b/deploy.cake index c02b35b545..af1f67543e 100644 --- a/deploy.cake +++ b/deploy.cake @@ -80,11 +80,13 @@ Task("DownloadGitHubReleaseArtifacts") // Have had missing artifacts before, lets fail early in that scenario if (!artifactLookup.ContainsKey("NuGetRefBuild")) { throw new Exception("NuGetRefBuild artifact missing"); } if (!artifactLookup.ContainsKey("NuGetCommandLineBuild")) { throw new Exception("NuGetCommandLineBuild artifact missing"); } + if (!artifactLookup.ContainsKey("NuGetExeDotNetCoreBuild")) { throw new Exception("NuGetExeDotNetCoreBuild artifact missing"); } if (!artifactLookup.ContainsKey("NuGetTaskBuild")) { throw new Exception("NuGetTaskBuild artifact missing"); } if (!artifactLookup.ContainsKey("NuGetExeBuild")) { throw new Exception("NuGetExeBuild artifact missing"); } if (!artifactLookup.ContainsKey("GemBuild")) { throw new Exception("GemBuild artifact missing"); } if (!artifactLookup.ContainsKey("GitVersionTfsTaskBuild")) { throw new Exception("GitVersionTfsTaskBuild artifact missing"); } if (!artifactLookup.ContainsKey("zip")) { throw new Exception("zip artifact missing"); } + if (!artifactLookup.ContainsKey("zip-dotnetcore")) { throw new Exception("zip-dotnetcore artifact missing"); } }); Task("Publish-NuGetPackage") @@ -121,6 +123,23 @@ Task("Publish-NuGetCommandLine") publishingError = true; }); +Task("Publish-NuGetExeDotNetCore") + .IsDependentOn("DownloadGitHubReleaseArtifacts") + .Does(() => +{ + NuGetPush( + "./releaseArtifacts/" + artifactLookup["NuGetExeDotNetCoreBuild"], + new NuGetPushSettings { + ApiKey = EnvironmentVariable("NuGetApiKey"), + Source = "https://www.nuget.org/api/v2/package" + }); +}) +.OnError(exception => +{ + Information("Publish-NuGet Task failed, but continuing with next Task..."); + publishingError = true; +}); + Task("Publish-MsBuildTask") .IsDependentOn("DownloadGitHubReleaseArtifacts") @@ -187,37 +206,61 @@ Task("Publish-VstsTask") } }); - -Task("Publish-DockerImage") - .IsDependentOn("DownloadGitHubReleaseArtifacts") - .Does(() => +// PublishDocker("gittools/gitversion", tag, "content.zip", "/some/path/DockerFile"); +bool PublishDocker(string name, tagName, contentZip, dockerFilePath, containerVolume) { + Information("Starting Docker Build for Image: " + name); + var username = EnvironmentVariable("DOCKER_USERNAME"); var password = EnvironmentVariable("DOCKER_PASSWORD"); - if (string.IsNullOrEmpty(username) || string.IsNullOrEmpty(password)) + + if (string.IsNullOrEmpty(username) || string.IsNullOrEmpty(password)) { Warning("Skipping docker publish due to missing credentials"); - return; + return false; } - var returnCode = StartProcess("docker", new ProcessSettings + // copy the docker file to a build directory, along with the contents of the specified content.zip. + // This directory should then contain all we need for the docker build. + var dockerBuildFolder = "./build/Docker/"; + CreateDirectory(dockerBuildFolder); + + //var folderName = name.Replace("/", "-"); + var dockerFileBuildFolder = dockerBuildFolder + name; + CreateDirectory(dockerFileBuildFolder); + + Information("Copying docker file to " + dockerFileBuildFolder); + CopyFiles(dockerFilePath, dockerFileBuildFolder); + + var contentPath = "/content"; + var contentFolder = dockerFileBuildFolder + contentPath; + + Information("Extracting docker image content to " + contentFolder); + Unzip(contentZip, contentFolder); + + var dockerFilePathForBuild = dockerFileBuildFolder + "/DockerFile"; + Information("Beginning Docker Build command for " + dockerFilePathForBuild); + + var returnCode = StartProcess("docker", new ProcessSettings { - Arguments = "build . --build-arg GitVersionZip=" + artifactLookup["zip"] + " --tag gittools/gitversion:" + tag + Arguments = "build -f " + dockerFilePathForBuild + " " + dockerFileBuildFolder + " --build-arg contentFolder=" + contentPath + " --tag " + name + ":" + tagName }); + if (returnCode != 0) { Information("Publish-DockerImage Task failed to build image, but continuing with next Task..."); publishingError = true; - return; + return false; } returnCode = StartProcess("docker", new ProcessSettings { - Arguments = "run -v " + System.IO.Directory.GetCurrentDirectory() + ":/repo gittools/gitversion:" + tag + Arguments = "run -v " + System.IO.Directory.GetCurrentDirectory() + ":" + containerVolume + " " + name + ":" + tag }); + if (returnCode != 0) { Information("Publish-DockerImage Task failed to run built image, but continuing with next Task..."); publishingError = true; - return; + return false; } // Login to dockerhub @@ -228,39 +271,51 @@ Task("Publish-DockerImage") if (returnCode != 0) { Information("Publish-DockerImage Task failed to login, but continuing with next Task..."); publishingError = true; - return; + return false; } // Publish Tag returnCode = StartProcess("docker", new ProcessSettings { - Arguments = "push gittools/gitversion:" + tag + Arguments = "push " + name + ":" + tag }); if (returnCode != 0) { Information("Publish-DockerImage Task failed push version tag, but continuing with next Task..."); publishingError = true; - return; + return false; } // Publish latest returnCode = StartProcess("docker", new ProcessSettings { - Arguments = "tag gittools/gitversion:" + tag + " gittools/gitversion:latest" + Arguments = "tag " + name + ":" + tag + " " + name + ":latest" }); if (returnCode != 0) { Information("Publish-DockerImage Task failed latest tag, but continuing with next Task..."); - publishingError = true; + publishingError = true; } + returnCode = StartProcess("docker", new ProcessSettings { - Arguments = "push gittools/gitversion:latest" + Arguments = "push " + name + ":latest" }); if (returnCode != 0) { Information("Publish-DockerImage Task failed latest tag, but continuing with next Task..."); publishingError = true; + return false; } + +} + +Task("Publish-DockerImage") + .IsDependentOn("DownloadGitHubReleaseArtifacts") + .Does(() => +{ + PublishDocker("gittools/gitversion", tag, artifactLookup["zip"], "src/Docker/Mono/DockerFile", "/repo"); + PublishDocker("gittools/gitversion-dotnetcore", tag, artifactLookup["zip-dotnetcore"], "src/Docker/DotNetCore/DockerFile", "c:/repo"); }); + Task("Deploy") .IsDependentOn("Publish-NuGetPackage") .IsDependentOn("Publish-NuGetCommandLine") diff --git a/src/Directory.Build.props b/src/Directory.Build.props new file mode 100644 index 0000000000..6e345ab46f --- /dev/null +++ b/src/Directory.Build.props @@ -0,0 +1,7 @@ + + + 1.3.1 + 4.2.3 + [1.0.185] + + \ No newline at end of file diff --git a/src/Docker/DotNetCore/Dockerfile b/src/Docker/DotNetCore/Dockerfile new file mode 100644 index 0000000000..62ae308c35 --- /dev/null +++ b/src/Docker/DotNetCore/Dockerfile @@ -0,0 +1,8 @@ +FROM microsoft/dotnet:2.0-runtime +LABEL maintainers="GitTools Maintainers" +ARG contentFolder + +WORKDIR /app +COPY $contentFolder/**/* ./ + +ENTRYPOINT ["dotnet", "GitVersion.dll"] \ No newline at end of file diff --git a/src/DockerBase/Dockerfile b/src/Docker/Mono/DockerBase/Dockerfile similarity index 100% rename from src/DockerBase/Dockerfile rename to src/Docker/Mono/DockerBase/Dockerfile diff --git a/src/DockerBase/readme b/src/Docker/Mono/DockerBase/readme similarity index 100% rename from src/DockerBase/readme rename to src/Docker/Mono/DockerBase/readme diff --git a/Dockerfile b/src/Docker/Mono/Dockerfile similarity index 71% rename from Dockerfile rename to src/Docker/Mono/Dockerfile index 35fa9a1b39..e765eb0be8 100644 --- a/Dockerfile +++ b/src/Docker/Mono/Dockerfile @@ -1,12 +1,10 @@ FROM gittools/libgit2sharp-mono MAINTAINER GitTools Maintainers -ARG GitVersionZip +ARG contentFolder -# Add GitVersion - -ADD ./releaseArtifacts/$GitVersionZip . -RUN unzip -d /usr/lib/GitVersion/ $GitVersionZip && rm $GitVersionZip +# Copy GitVersion +COPY $contentFolder /usr/lib/GitVersion/ WORKDIR /usr/lib/GitVersion/ # Libgit2 can't resolve relative paths, patch to absolute path diff --git a/src/GitVersion.sln b/src/GitVersion.sln index 6af6252047..c018de2420 100644 --- a/src/GitVersion.sln +++ b/src/GitVersion.sln @@ -1,21 +1,20 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 14 -VisualStudioVersion = 14.0.25420.1 +# Visual Studio 15 +VisualStudioVersion = 15.0.27130.2024 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GitVersionExe", "GitVersionExe\GitVersionExe.csproj", "{C3578A7B-09A6-4444-9383-0DEAFA4958BD}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GitVersionExe", "GitVersionExe\GitVersionExe.csproj", "{C3578A7B-09A6-4444-9383-0DEAFA4958BD}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GitVersionTask.Tests", "GitVersionTask.Tests\GitVersionTask.Tests.csproj", "{5A86453B-96FB-4B6E-A283-225BB9F753D3}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GitVersionTask.Tests", "GitVersionTask.Tests\GitVersionTask.Tests.csproj", "{5A86453B-96FB-4B6E-A283-225BB9F753D3}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GitVersionTask", "GitVersionTask\GitVersionTask.csproj", "{F7AC0E71-3E9A-4F6D-B986-E004825A48E1}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GitVersionCore.Tests", "GitVersionCore.Tests\GitVersionCore.Tests.csproj", "{BF905F84-382C-440D-92F5-C61108626D8D}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GitVersionCore.Tests", "GitVersionCore.Tests\GitVersionCore.Tests.csproj", "{BF905F84-382C-440D-92F5-C61108626D8D}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{3EFFC5D6-88D0-49D9-BB53-E1B7EB49DD45}" ProjectSection(SolutionItems) = preProject ..\.gitattributes = ..\.gitattributes ..\.gitignore = ..\.gitignore ..\.travis.yml = ..\.travis.yml + ..\appveyor.deploy.yml = ..\appveyor.deploy.yml ..\appveyor.yml = ..\appveyor.yml ..\BREAKING CHANGES.md = ..\BREAKING CHANGES.md ..\build.cake = ..\build.cake @@ -23,18 +22,22 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution ..\build.sh = ..\build.sh ..\CONTRIBUTING.md = ..\CONTRIBUTING.md ..\deploy.cake = ..\deploy.cake + ..\deploy.ps1 = ..\deploy.ps1 + Directory.Build.props = Directory.Build.props ..\GitVersion.yml = ..\GitVersion.yml ..\LICENSE = ..\LICENSE ..\mkdocs.yml = ..\mkdocs.yml + NuGet.config = NuGet.config ..\README.md = ..\README.md EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GitVersionCore", "GitVersionCore\GitVersionCore.csproj", "{F9741A0D-B9D7-4557-9A1C-A7252C1071F5}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GitVersionCore", "GitVersionCore\GitVersionCore.csproj", "{F9741A0D-B9D7-4557-9A1C-A7252C1071F5}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GitVersionExe.Tests", "GitVersionExe.Tests\GitVersionExe.Tests.csproj", "{75C2BE85-1DAF-4E34-8305-B17AFAA982A6}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GitVersionExe.Tests", "GitVersionExe.Tests\GitVersionExe.Tests.csproj", "{75C2BE85-1DAF-4E34-8305-B17AFAA982A6}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "TfsTask", "TfsTask", "{A0ED1410-E970-45E8-A357-05605E2B7BFF}" ProjectSection(SolutionItems) = preProject + GitVersionTfsTask\BuildTs.ps1 = GitVersionTfsTask\BuildTs.ps1 GitVersionTfsTask\Create-Vsix.ps1 = GitVersionTfsTask\Create-Vsix.ps1 GitVersionTfsTask\extension-icon.png = GitVersionTfsTask\extension-icon.png GitVersionTfsTask\GitVersion.ts = GitVersionTfsTask\GitVersion.ts @@ -45,6 +48,26 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "TfsTask", "TfsTask", "{A0ED GitVersionTfsTask\Update-GitVersionTfsTaskVersion.ps1 = GitVersionTfsTask\Update-GitVersionTfsTaskVersion.ps1 EndProjectSection EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GitVersionTask", "GitVersionTask\GitVersionTask.csproj", "{F7AC0E71-3E9A-4F6D-B986-E004825A48E1}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Docker", "Docker", "{98C7108A-09FD-436D-8CA5-DF19E0FC5F8D}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Mono", "Mono", "{6A6E0584-5392-4F03-8C14-799D400941AC}" + ProjectSection(SolutionItems) = preProject + Docker\Mono\Dockerfile = Docker\Mono\Dockerfile + EndProjectSection +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "DotnetCore", "DotnetCore", "{E78ADE9E-5573-48E2-890C-EF59CB1BA7ED}" + ProjectSection(SolutionItems) = preProject + Docker\DotNetCore\Dockerfile = Docker\DotNetCore\Dockerfile + EndProjectSection +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "DockerBase", "DockerBase", "{C4479215-01B1-4EC0-A33D-C90D1579BD13}" + ProjectSection(SolutionItems) = preProject + Docker\Mono\DockerBase\Dockerfile = Docker\Mono\DockerBase\Dockerfile + Docker\Mono\DockerBase\readme = Docker\Mono\DockerBase\readme + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -59,10 +82,6 @@ Global {5A86453B-96FB-4B6E-A283-225BB9F753D3}.Debug|Any CPU.Build.0 = Debug|Any CPU {5A86453B-96FB-4B6E-A283-225BB9F753D3}.Release|Any CPU.ActiveCfg = Release|Any CPU {5A86453B-96FB-4B6E-A283-225BB9F753D3}.Release|Any CPU.Build.0 = Release|Any CPU - {F7AC0E71-3E9A-4F6D-B986-E004825A48E1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {F7AC0E71-3E9A-4F6D-B986-E004825A48E1}.Debug|Any CPU.Build.0 = Debug|Any CPU - {F7AC0E71-3E9A-4F6D-B986-E004825A48E1}.Release|Any CPU.ActiveCfg = Release|Any CPU - {F7AC0E71-3E9A-4F6D-B986-E004825A48E1}.Release|Any CPU.Build.0 = Release|Any CPU {BF905F84-382C-440D-92F5-C61108626D8D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {BF905F84-382C-440D-92F5-C61108626D8D}.Debug|Any CPU.Build.0 = Debug|Any CPU {BF905F84-382C-440D-92F5-C61108626D8D}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -75,8 +94,20 @@ Global {75C2BE85-1DAF-4E34-8305-B17AFAA982A6}.Debug|Any CPU.Build.0 = Debug|Any CPU {75C2BE85-1DAF-4E34-8305-B17AFAA982A6}.Release|Any CPU.ActiveCfg = Release|Any CPU {75C2BE85-1DAF-4E34-8305-B17AFAA982A6}.Release|Any CPU.Build.0 = Release|Any CPU + {F7AC0E71-3E9A-4F6D-B986-E004825A48E1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F7AC0E71-3E9A-4F6D-B986-E004825A48E1}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F7AC0E71-3E9A-4F6D-B986-E004825A48E1}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F7AC0E71-3E9A-4F6D-B986-E004825A48E1}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {6A6E0584-5392-4F03-8C14-799D400941AC} = {98C7108A-09FD-436D-8CA5-DF19E0FC5F8D} + {E78ADE9E-5573-48E2-890C-EF59CB1BA7ED} = {98C7108A-09FD-436D-8CA5-DF19E0FC5F8D} + {C4479215-01B1-4EC0-A33D-C90D1579BD13} = {6A6E0584-5392-4F03-8C14-799D400941AC} + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {0C1C310E-7A4D-4032-878B-6DC375894C49} + EndGlobalSection EndGlobal diff --git a/src/GitVersionCore.Tests/Approved/fs/AssemblyInfoFileUpdateTests.ShouldAddAssemblyInformationalVersionWhenUpdatingAssemblyVersionFile.approved.txt b/src/GitVersionCore.Tests/Approved/fs/AssemblyInfoFileUpdateTests.ShouldAddAssemblyInformationalVersionWhenUpdatingAssemblyVersionFile.approved.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/GitVersionCore.Tests/Approved/fs/AssemblyInfoFileUpdateTests.ShouldCreateAssemblyInfoFileAtPathWhenNotExistsAndEnsureAssemblyInfo.approved.txt b/src/GitVersionCore.Tests/Approved/fs/AssemblyInfoFileUpdateTests.ShouldCreateAssemblyInfoFileAtPathWhenNotExistsAndEnsureAssemblyInfo.approved.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/GitVersionCore.Tests/Approved/fs/AssemblyInfoFileUpdateTests.ShouldCreateAssemblyInfoFileWhenNotExistsAndEnsureAssemblyInfo.approved.txt b/src/GitVersionCore.Tests/Approved/fs/AssemblyInfoFileUpdateTests.ShouldCreateAssemblyInfoFileWhenNotExistsAndEnsureAssemblyInfo.approved.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/GitVersionCore.Tests/Approved/fs/AssemblyInfoFileUpdateTests.ShouldCreateAssemblyInfoFilesAtPathWhenNotExistsAndEnsureAssemblyInfo.approved.txt b/src/GitVersionCore.Tests/Approved/fs/AssemblyInfoFileUpdateTests.ShouldCreateAssemblyInfoFilesAtPathWhenNotExistsAndEnsureAssemblyInfo.approved.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/GitVersionCore.Tests/Approved/fs/AssemblyInfoFileUpdateTests.ShouldNotAddAssemblyInformationalVersionWhenUpdatingAssemblyVersionFileWhenVersionSchemeIsNone.approved.txt b/src/GitVersionCore.Tests/Approved/fs/AssemblyInfoFileUpdateTests.ShouldNotAddAssemblyInformationalVersionWhenUpdatingAssemblyVersionFileWhenVersionSchemeIsNone.approved.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/GitVersionCore.Tests/Approved/fs/AssemblyInfoFileUpdateTests.ShouldNotReplaceAssemblyVersionWhenVersionSchemeIsNone.approved.txt b/src/GitVersionCore.Tests/Approved/fs/AssemblyInfoFileUpdateTests.ShouldNotReplaceAssemblyVersionWhenVersionSchemeIsNone.approved.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/GitVersionCore.Tests/Approved/vb/AssemblyInfoFileUpdateTests.ShouldAddAssemblyInformationalVersionWhenUpdatingAssemblyVersionFile.approved.txt b/src/GitVersionCore.Tests/Approved/vb/AssemblyInfoFileUpdateTests.ShouldAddAssemblyInformationalVersionWhenUpdatingAssemblyVersionFile.approved.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/GitVersionCore.Tests/Approved/vb/AssemblyInfoFileUpdateTests.ShouldCreateAssemblyInfoFileAtPathWhenNotExistsAndEnsureAssemblyInfo.approved.txt b/src/GitVersionCore.Tests/Approved/vb/AssemblyInfoFileUpdateTests.ShouldCreateAssemblyInfoFileAtPathWhenNotExistsAndEnsureAssemblyInfo.approved.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/GitVersionCore.Tests/Approved/vb/AssemblyInfoFileUpdateTests.ShouldCreateAssemblyInfoFileWhenNotExistsAndEnsureAssemblyInfo.approved.txt b/src/GitVersionCore.Tests/Approved/vb/AssemblyInfoFileUpdateTests.ShouldCreateAssemblyInfoFileWhenNotExistsAndEnsureAssemblyInfo.approved.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/GitVersionCore.Tests/Approved/vb/AssemblyInfoFileUpdateTests.ShouldCreateAssemblyInfoFilesAtPathWhenNotExistsAndEnsureAssemblyInfo.approved.txt b/src/GitVersionCore.Tests/Approved/vb/AssemblyInfoFileUpdateTests.ShouldCreateAssemblyInfoFilesAtPathWhenNotExistsAndEnsureAssemblyInfo.approved.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/GitVersionCore.Tests/Approved/vb/AssemblyInfoFileUpdateTests.ShouldNotAddAssemblyInformationalVersionWhenUpdatingAssemblyVersionFileWhenVersionSchemeIsNone.approved.txt b/src/GitVersionCore.Tests/Approved/vb/AssemblyInfoFileUpdateTests.ShouldNotAddAssemblyInformationalVersionWhenUpdatingAssemblyVersionFileWhenVersionSchemeIsNone.approved.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/GitVersionCore.Tests/Approved/vb/AssemblyInfoFileUpdateTests.ShouldNotReplaceAssemblyVersionWhenVersionSchemeIsNone.approved.txt b/src/GitVersionCore.Tests/Approved/vb/AssemblyInfoFileUpdateTests.ShouldNotReplaceAssemblyVersionWhenVersionSchemeIsNone.approved.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/GitVersionCore.Tests/AssemblyFileVersionTests.cs b/src/GitVersionCore.Tests/AssemblyFileVersionTests.cs index e09f186191..db65691e48 100644 --- a/src/GitVersionCore.Tests/AssemblyFileVersionTests.cs +++ b/src/GitVersionCore.Tests/AssemblyFileVersionTests.cs @@ -6,7 +6,7 @@ namespace GitVersionCore.Tests using Shouldly; [TestFixture] - public class AssemblyFileVersionTests + public class AssemblyFileVersionTests : TestBase { [TestCase(AssemblyFileVersioningScheme.None, 1, 2, 3, 4, null)] [TestCase(AssemblyFileVersioningScheme.Major, 1, 2, 3, 4, "1.0.0.0")] diff --git a/src/GitVersionCore.Tests/AssemblyInfoFileUpdaterTests.cs b/src/GitVersionCore.Tests/AssemblyInfoFileUpdaterTests.cs index dadc0c4bad..38593e255c 100644 --- a/src/GitVersionCore.Tests/AssemblyInfoFileUpdaterTests.cs +++ b/src/GitVersionCore.Tests/AssemblyInfoFileUpdaterTests.cs @@ -10,7 +10,7 @@ using Shouldly; [TestFixture] -public class AssemblyInfoFileUpdaterTests +public class AssemblyInfoFileUpdaterTests : TestBase { [SetUp] public void Setup() @@ -424,7 +424,7 @@ public void ShouldAddAssemblyInformationalVersionWhenUpdatingAssemblyVersionFile using (var assemblyInfoFileUpdater = new AssemblyInfoFileUpdater(assemblyInfoFile, workingDir, variables, fileSystem, false)) { assemblyInfoFileUpdater.Update(); - + assemblyFileContent = fileSystem.ReadAllText(fileName); assemblyFileContent.ShouldMatchApproved(c => c.SubFolder(Path.Combine("Approved", fileExtension))); } diff --git a/src/GitVersionCore.Tests/BuildServers/BuildServerBaseTests.cs b/src/GitVersionCore.Tests/BuildServers/BuildServerBaseTests.cs index 2e7fc23413..c224fdc611 100644 --- a/src/GitVersionCore.Tests/BuildServers/BuildServerBaseTests.cs +++ b/src/GitVersionCore.Tests/BuildServers/BuildServerBaseTests.cs @@ -6,7 +6,7 @@ using Shouldly; [TestFixture] -public class BuildServerBaseTests +public class BuildServerBaseTests : TestBase { [Test] public void BuildNumberIsFullSemVer() diff --git a/src/GitVersionCore.Tests/BuildServers/ContinuaCiTests.cs b/src/GitVersionCore.Tests/BuildServers/ContinuaCiTests.cs index f039f7f546..38edab1c24 100644 --- a/src/GitVersionCore.Tests/BuildServers/ContinuaCiTests.cs +++ b/src/GitVersionCore.Tests/BuildServers/ContinuaCiTests.cs @@ -3,7 +3,7 @@ using NUnit.Framework; [TestFixture] -public class ContinuaCiTests +public class ContinuaCiTests : TestBase { [Test] diff --git a/src/GitVersionCore.Tests/BuildServers/EnvironmentVariableJenkinsTests.cs b/src/GitVersionCore.Tests/BuildServers/EnvironmentVariableJenkinsTests.cs index 511822d2c4..8a651fd4e7 100644 --- a/src/GitVersionCore.Tests/BuildServers/EnvironmentVariableJenkinsTests.cs +++ b/src/GitVersionCore.Tests/BuildServers/EnvironmentVariableJenkinsTests.cs @@ -1,10 +1,11 @@ using System; using GitVersion; +using GitVersionCore.Tests; using NUnit.Framework; using Shouldly; [TestFixture] -public class EnvironmentVariableJenkinsTests +public class EnvironmentVariableJenkinsTests : TestBase { string key = "JENKINS_URL"; string branch = "GIT_BRANCH"; diff --git a/src/GitVersionCore.Tests/BuildServers/GitLabCiMessageGenerationTest.cs b/src/GitVersionCore.Tests/BuildServers/GitLabCiMessageGenerationTest.cs index 2c6ea5e39d..12d6c2e60e 100755 --- a/src/GitVersionCore.Tests/BuildServers/GitLabCiMessageGenerationTest.cs +++ b/src/GitVersionCore.Tests/BuildServers/GitLabCiMessageGenerationTest.cs @@ -8,7 +8,7 @@ using System.Reflection; [TestFixture] -public class GitLabCiMessageGenerationTests +public class GitLabCiMessageGenerationTests : TestBase { [Test] public void GenerateSetVersionMessageReturnsVersionAsIs_AlthoughThisIsNotUsedByJenkins() diff --git a/src/GitVersionCore.Tests/BuildServers/JenkinsMessageGenerationTests.cs b/src/GitVersionCore.Tests/BuildServers/JenkinsMessageGenerationTests.cs index 418463dbc9..ed2d13a948 100644 --- a/src/GitVersionCore.Tests/BuildServers/JenkinsMessageGenerationTests.cs +++ b/src/GitVersionCore.Tests/BuildServers/JenkinsMessageGenerationTests.cs @@ -8,7 +8,7 @@ using System.Reflection; [TestFixture] -public class JenkinsMessageGenerationTests +public class JenkinsMessageGenerationTests : TestBase { [Test] public void GenerateSetVersionMessageReturnsVersionAsIs_AlthoughThisIsNotUsedByJenkins() diff --git a/src/GitVersionCore.Tests/BuildServers/MyGetTests.cs b/src/GitVersionCore.Tests/BuildServers/MyGetTests.cs index 82a420b7bb..440ca933a9 100644 --- a/src/GitVersionCore.Tests/BuildServers/MyGetTests.cs +++ b/src/GitVersionCore.Tests/BuildServers/MyGetTests.cs @@ -3,7 +3,7 @@ using NUnit.Framework; [TestFixture] -public class MyGetTests +public class MyGetTests : TestBase { [Test] public void Develop_branch() diff --git a/src/GitVersionCore.Tests/BuildServers/TeamCityTests.cs b/src/GitVersionCore.Tests/BuildServers/TeamCityTests.cs index c391aca037..3731abfadf 100644 --- a/src/GitVersionCore.Tests/BuildServers/TeamCityTests.cs +++ b/src/GitVersionCore.Tests/BuildServers/TeamCityTests.cs @@ -3,7 +3,7 @@ using NUnit.Framework; [TestFixture] -public class TeamCityTests +public class TeamCityTests : TestBase { [Test] public void Develop_branch() diff --git a/src/GitVersionCore.Tests/BuildServers/VsoAgentBuildNumberTests.cs b/src/GitVersionCore.Tests/BuildServers/VsoAgentBuildNumberTests.cs index c3aecb813a..16552b821d 100644 --- a/src/GitVersionCore.Tests/BuildServers/VsoAgentBuildNumberTests.cs +++ b/src/GitVersionCore.Tests/BuildServers/VsoAgentBuildNumberTests.cs @@ -5,7 +5,7 @@ using Shouldly; [TestFixture] -public class VsoAgentBuildNumberTests +public class VsoAgentBuildNumberTests : TestBase { string key = "BUILD_BUILDNUMBER"; string logPrefix = "##vso[build.updatebuildnumber]"; diff --git a/src/GitVersionCore.Tests/BuildServers/VsoAgentTests.cs b/src/GitVersionCore.Tests/BuildServers/VsoAgentTests.cs index e9e629e632..f78abd3476 100644 --- a/src/GitVersionCore.Tests/BuildServers/VsoAgentTests.cs +++ b/src/GitVersionCore.Tests/BuildServers/VsoAgentTests.cs @@ -5,7 +5,7 @@ using Shouldly; [TestFixture] -public class VsoAgentTests +public class VsoAgentTests : TestBase { string key = "BUILD_BUILDNUMBER"; diff --git a/src/GitVersionCore.Tests/CommitDateTests.cs b/src/GitVersionCore.Tests/CommitDateTests.cs index 8520786baf..73235a0184 100644 --- a/src/GitVersionCore.Tests/CommitDateTests.cs +++ b/src/GitVersionCore.Tests/CommitDateTests.cs @@ -9,7 +9,7 @@ namespace GitVersionCore.Tests { [TestFixture] - public class CommitDateTests + public class CommitDateTests : TestBase { [Test] [TestCase("yyyy-MM-dd", "2017-10-06")] diff --git a/src/GitVersionCore.Tests/ConfigProviderTests.cs b/src/GitVersionCore.Tests/ConfigProviderTests.cs index 090561e920..035d4d15b6 100644 --- a/src/GitVersionCore.Tests/ConfigProviderTests.cs +++ b/src/GitVersionCore.Tests/ConfigProviderTests.cs @@ -1,9 +1,10 @@ +using GitTools; using GitVersion; using GitVersion.Helpers; +using GitVersionCore.Tests; using NUnit.Framework; using Shouldly; using System; -using System.ComponentModel; using System.IO; using System.Linq; using System.Reflection; @@ -11,7 +12,7 @@ using YamlDotNet.Serialization; [TestFixture] -public class ConfigProviderTests +public class ConfigProviderTests : TestBase { private const string DefaultRepoPath = "c:\\MyGitRepo"; private const string DefaultWorkingPath = "c:\\MyGitRepo\\Working"; diff --git a/src/GitVersionCore.Tests/Configuration/IgnoreConfigTests.cs b/src/GitVersionCore.Tests/Configuration/IgnoreConfigTests.cs index aae3807a23..513e1327a6 100644 --- a/src/GitVersionCore.Tests/Configuration/IgnoreConfigTests.cs +++ b/src/GitVersionCore.Tests/Configuration/IgnoreConfigTests.cs @@ -8,7 +8,7 @@ namespace GitVersionCore.Tests.Configuration { [TestFixture] - public class IgnoreConfigTests + public class IgnoreConfigTests : TestBase { [Test] public void CanDeserialize() diff --git a/src/GitVersionCore.Tests/DocumentationTests.cs b/src/GitVersionCore.Tests/DocumentationTests.cs index b2aed4ab2f..660ea9f356 100644 --- a/src/GitVersionCore.Tests/DocumentationTests.cs +++ b/src/GitVersionCore.Tests/DocumentationTests.cs @@ -4,7 +4,7 @@ using System.Reflection; using GitVersion; - +using GitVersionCore.Tests; using NUnit.Framework; using Shouldly; @@ -12,7 +12,7 @@ using YamlDotNet.Serialization; [TestFixture] -public class DocumentationTests +public class DocumentationTests : TestBase { private DirectoryInfo docsDirectory; diff --git a/src/GitVersionCore.Tests/DynamicRepositoryTests.cs b/src/GitVersionCore.Tests/DynamicRepositoryTests.cs index 968f691ae0..a8a2782ca8 100644 --- a/src/GitVersionCore.Tests/DynamicRepositoryTests.cs +++ b/src/GitVersionCore.Tests/DynamicRepositoryTests.cs @@ -1,9 +1,10 @@ using System.IO; using GitVersion; +using GitVersionCore.Tests; using NUnit.Framework; [TestFixture] -public class DynamicRepositoryTests +public class DynamicRepositoryTests : TestBase { string workDirectory; diff --git a/src/GitVersionCore.Tests/ExecuteCoreTests.cs b/src/GitVersionCore.Tests/ExecuteCoreTests.cs index d167b60a52..bb6be7a756 100644 --- a/src/GitVersionCore.Tests/ExecuteCoreTests.cs +++ b/src/GitVersionCore.Tests/ExecuteCoreTests.cs @@ -1,6 +1,7 @@ using GitTools.Testing; using GitVersion; using GitVersion.Helpers; +using GitVersionCore.Tests; using NUnit.Framework; using Shouldly; using System; @@ -8,7 +9,7 @@ using System.Text; [TestFixture] -public class ExecuteCoreTests +public class ExecuteCoreTests : TestBase { IFileSystem fileSystem; diff --git a/src/GitVersionCore.Tests/FodyWeavers.xml b/src/GitVersionCore.Tests/FodyWeavers.xml deleted file mode 100644 index aeb3452852..0000000000 --- a/src/GitVersionCore.Tests/FodyWeavers.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/src/GitVersionCore.Tests/GitRepoMetadataProviderTests.cs b/src/GitVersionCore.Tests/GitRepoMetadataProviderTests.cs index ec7d50c345..aa247383f0 100644 --- a/src/GitVersionCore.Tests/GitRepoMetadataProviderTests.cs +++ b/src/GitVersionCore.Tests/GitRepoMetadataProviderTests.cs @@ -8,7 +8,7 @@ using Shouldly; [TestFixture] - public class GitRepoMetadataProviderTests + public class GitRepoMetadataProviderTests : TestBase { [Test] public void FindsCorrectMergeBaseForForwardMerge() diff --git a/src/GitVersionCore.Tests/GitVersionContextTests.cs b/src/GitVersionCore.Tests/GitVersionContextTests.cs index 21dcbd4d22..96440bf28a 100644 --- a/src/GitVersionCore.Tests/GitVersionContextTests.cs +++ b/src/GitVersionCore.Tests/GitVersionContextTests.cs @@ -7,7 +7,7 @@ using Shouldly; using System.Collections.Generic; - public class GitVersionContextTests + public class GitVersionContextTests : TestBase { [Test] [Theory] diff --git a/src/GitVersionCore.Tests/GitVersionCore.Tests.csproj b/src/GitVersionCore.Tests/GitVersionCore.Tests.csproj index 6c7f1ad723..83cde8af1c 100644 --- a/src/GitVersionCore.Tests/GitVersionCore.Tests.csproj +++ b/src/GitVersionCore.Tests/GitVersionCore.Tests.csproj @@ -1,221 +1,74 @@ - - - - + + - Debug - AnyCPU - {BF905F84-382C-440D-92F5-C61108626D8D} + net461 + Library - Properties GitVersionCore.Tests GitVersionCore.Tests - v4.5 - 6 - 512 - - - + + false + false + false + false + false + true + true full false - bin\Debug\ DEBUG;TRACE - prompt - 4 - false full false bin\Release\ TRACE - prompt - 4 - false true - + + - - ..\packages\FluentDateTime.1.13.0\lib\NET35\FluentDateTime.dll - True - - - ..\packages\GitTools.Core.1.2.1-beta0001\lib\net45\GitTools.Core.dll - True - - - ..\packages\GitTools.Testing.1.1.1-beta0001\lib\net4\GitTools.Testing.dll - True - - - ..\packages\LibGit2Sharp.0.23.0-pre20160922233542\lib\net40\LibGit2Sharp.dll - True - - - ..\packages\NSubstitute.1.10.0.0\lib\net45\NSubstitute.dll - True - - - ..\packages\NUnit.3.6.0\lib\net45\nunit.framework.dll - True - - - ..\packages\Shouldly.2.7.0\lib\net40\Shouldly.dll - True - + + + + + + + + + + + + + + - - - ..\packages\TestStack.ConventionTests.3.0.0\lib\net40\TestStack.ConventionTests.dll - True - - - ..\packages\YamlDotNet.3.8.0\lib\net35\YamlDotNet.dll - True - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + - - + + Designer + - - {f9741a0d-b9d7-4557-9a1c-a7252c1071f5} - GitVersionCore - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - - - + \ No newline at end of file diff --git a/src/GitVersionCore.Tests/GitVersionInformationGeneratorTests.cs b/src/GitVersionCore.Tests/GitVersionInformationGeneratorTests.cs index a22a8bca1d..49416daadd 100644 --- a/src/GitVersionCore.Tests/GitVersionInformationGeneratorTests.cs +++ b/src/GitVersionCore.Tests/GitVersionInformationGeneratorTests.cs @@ -11,7 +11,7 @@ namespace GitVersionCore.Tests { [TestFixture] - public class GitVersionInformationGeneratorTests + public class GitVersionInformationGeneratorTests : TestBase { [SetUp] public void Setup() diff --git a/src/GitVersionCore.Tests/InformationalVersionBuilderTests.cs b/src/GitVersionCore.Tests/InformationalVersionBuilderTests.cs index cc23f81f69..dc2416f1df 100644 --- a/src/GitVersionCore.Tests/InformationalVersionBuilderTests.cs +++ b/src/GitVersionCore.Tests/InformationalVersionBuilderTests.cs @@ -1,9 +1,10 @@ using System; using GitVersion; +using GitVersionCore.Tests; using NUnit.Framework; [TestFixture] -public class InformationalVersionBuilderTests +public class InformationalVersionBuilderTests : TestBase { [TestCase("feature1", "a682956dc1a2752aa24597a0f5cd939f93614509", 1, 2, 3, "unstable", 1, "1.2.3-unstable+1.Branch.feature1.Sha.a682956dc1a2752aa24597a0f5cd939f93614509")] [TestCase("develop", "a682956dc1a2752aa24597a0f5cd939f93614509", 1, 2, 3, "alpha645", null, "1.2.3-alpha.645+Branch.develop.Sha.a682956dc1a2752aa24597a0f5cd939f93614509")] diff --git a/src/GitVersionCore.Tests/Init/InitScenarios.cs b/src/GitVersionCore.Tests/Init/InitScenarios.cs index 57748cc488..4978a81425 100644 --- a/src/GitVersionCore.Tests/Init/InitScenarios.cs +++ b/src/GitVersionCore.Tests/Init/InitScenarios.cs @@ -9,7 +9,7 @@ using TestStack.ConventionTests.ConventionData; [TestFixture] - public class InitScenarios + public class InitScenarios : TestBase { [SetUp] public void Setup() diff --git a/src/GitVersionCore.Tests/IntegrationTests/BranchWithoutCommitScenario.cs b/src/GitVersionCore.Tests/IntegrationTests/BranchWithoutCommitScenario.cs index e7b3793ca9..aec7d8d465 100644 --- a/src/GitVersionCore.Tests/IntegrationTests/BranchWithoutCommitScenario.cs +++ b/src/GitVersionCore.Tests/IntegrationTests/BranchWithoutCommitScenario.cs @@ -4,7 +4,7 @@ using NUnit.Framework; [TestFixture] -public class BranchWithoutCommitScenario +public class BranchWithoutCommitScenario : TestBase { [Test] public void CanTakeVersionFromReleaseBranch() diff --git a/src/GitVersionCore.Tests/IntegrationTests/DevelopScenarios.cs b/src/GitVersionCore.Tests/IntegrationTests/DevelopScenarios.cs index e95d420615..72d9029b9e 100644 --- a/src/GitVersionCore.Tests/IntegrationTests/DevelopScenarios.cs +++ b/src/GitVersionCore.Tests/IntegrationTests/DevelopScenarios.cs @@ -6,7 +6,7 @@ using System.Collections.Generic; [TestFixture] -public class DevelopScenarios +public class DevelopScenarios : TestBase { [Test] public void WhenDevelopHasMultipleCommits_SpecifyExistingCommitId() diff --git a/src/GitVersionCore.Tests/IntegrationTests/DocumentationSamples.cs b/src/GitVersionCore.Tests/IntegrationTests/DocumentationSamples.cs index d61baa7d12..ed834cbd8d 100644 --- a/src/GitVersionCore.Tests/IntegrationTests/DocumentationSamples.cs +++ b/src/GitVersionCore.Tests/IntegrationTests/DocumentationSamples.cs @@ -6,7 +6,7 @@ using Shouldly; [TestFixture] -public class DocumentationSamples +public class DocumentationSamples : TestBase { [Test] public void GitFlowFeatureBranch() diff --git a/src/GitVersionCore.Tests/IntegrationTests/FeatureBranchScenarios.cs b/src/GitVersionCore.Tests/IntegrationTests/FeatureBranchScenarios.cs index 7d5bf8c5ae..7bd7506d1a 100644 --- a/src/GitVersionCore.Tests/IntegrationTests/FeatureBranchScenarios.cs +++ b/src/GitVersionCore.Tests/IntegrationTests/FeatureBranchScenarios.cs @@ -6,7 +6,7 @@ using NUnit.Framework; [TestFixture] -public class FeatureBranchScenarios +public class FeatureBranchScenarios : TestBase { [Test] public void ShouldInheritIncrementCorrectlyWithMultiplePossibleParentsAndWeirdlyNamedDevelopBranch() diff --git a/src/GitVersionCore.Tests/IntegrationTests/FileSystemTests.cs b/src/GitVersionCore.Tests/IntegrationTests/FileSystemTests.cs index b047022b24..378c30e123 100644 --- a/src/GitVersionCore.Tests/IntegrationTests/FileSystemTests.cs +++ b/src/GitVersionCore.Tests/IntegrationTests/FileSystemTests.cs @@ -2,13 +2,13 @@ using System.Text; using GitVersion.Helpers; - +using GitVersionCore.Tests; using NUnit.Framework; using Shouldly; [TestFixture] -public class FileSystemTests +public class FileSystemTests : TestBase { public string TempFilePath { get; set; } diff --git a/src/GitVersionCore.Tests/IntegrationTests/HotfixBranchScenarios.cs b/src/GitVersionCore.Tests/IntegrationTests/HotfixBranchScenarios.cs index 285a542958..8481cd3295 100644 --- a/src/GitVersionCore.Tests/IntegrationTests/HotfixBranchScenarios.cs +++ b/src/GitVersionCore.Tests/IntegrationTests/HotfixBranchScenarios.cs @@ -5,7 +5,7 @@ using NUnit.Framework; [TestFixture] -public class HotfixBranchScenarios +public class HotfixBranchScenarios : TestBase { [Test] // This test actually validates #465 as well diff --git a/src/GitVersionCore.Tests/IntegrationTests/MainlineDevelopmentMode.cs b/src/GitVersionCore.Tests/IntegrationTests/MainlineDevelopmentMode.cs index f062d66a9c..e5836e87e3 100644 --- a/src/GitVersionCore.Tests/IntegrationTests/MainlineDevelopmentMode.cs +++ b/src/GitVersionCore.Tests/IntegrationTests/MainlineDevelopmentMode.cs @@ -8,7 +8,7 @@ using NUnit.Framework; using System.Collections.Generic; -public class MainlineDevelopmentMode +public class MainlineDevelopmentMode : TestBase { private Config config = new Config { diff --git a/src/GitVersionCore.Tests/IntegrationTests/MasterScenarios.cs b/src/GitVersionCore.Tests/IntegrationTests/MasterScenarios.cs index 93f9fc3832..bc5f4dded1 100644 --- a/src/GitVersionCore.Tests/IntegrationTests/MasterScenarios.cs +++ b/src/GitVersionCore.Tests/IntegrationTests/MasterScenarios.cs @@ -5,7 +5,7 @@ using NUnit.Framework; [TestFixture] -public class MasterScenarios +public class MasterScenarios : TestBase { [Test] public void CanHandleContinuousDelivery() diff --git a/src/GitVersionCore.Tests/IntegrationTests/OtherBranchScenarios.cs b/src/GitVersionCore.Tests/IntegrationTests/OtherBranchScenarios.cs index c1c03b5243..0efcc15121 100644 --- a/src/GitVersionCore.Tests/IntegrationTests/OtherBranchScenarios.cs +++ b/src/GitVersionCore.Tests/IntegrationTests/OtherBranchScenarios.cs @@ -5,7 +5,7 @@ using Shouldly; [TestFixture] -public class OtherBranchScenarios +public class OtherBranchScenarios : TestBase { [Test] public void CanTakeVersionFromReleaseBranch() diff --git a/src/GitVersionCore.Tests/IntegrationTests/OtherScenarios.cs b/src/GitVersionCore.Tests/IntegrationTests/OtherScenarios.cs index 5fef1447c6..e4bda5e637 100644 --- a/src/GitVersionCore.Tests/IntegrationTests/OtherScenarios.cs +++ b/src/GitVersionCore.Tests/IntegrationTests/OtherScenarios.cs @@ -8,7 +8,7 @@ using System.Collections.Generic; [TestFixture] - public class OtherScenarios + public class OtherScenarios : TestBase { // This is an attempt to automatically resolve the issue where you cannot build // when multiple branches point at the same commit diff --git a/src/GitVersionCore.Tests/IntegrationTests/PullRequestScenarios.cs b/src/GitVersionCore.Tests/IntegrationTests/PullRequestScenarios.cs index 73951c9068..558233eed3 100644 --- a/src/GitVersionCore.Tests/IntegrationTests/PullRequestScenarios.cs +++ b/src/GitVersionCore.Tests/IntegrationTests/PullRequestScenarios.cs @@ -5,7 +5,7 @@ using NUnit.Framework; [TestFixture] -public class PullRequestScenarios +public class PullRequestScenarios : TestBase { [Test] public void CanCalculatePullRequestChanges() diff --git a/src/GitVersionCore.Tests/IntegrationTests/ReleaseBranchScenarios.cs b/src/GitVersionCore.Tests/IntegrationTests/ReleaseBranchScenarios.cs index 0dacc90c58..06f96b35e1 100644 --- a/src/GitVersionCore.Tests/IntegrationTests/ReleaseBranchScenarios.cs +++ b/src/GitVersionCore.Tests/IntegrationTests/ReleaseBranchScenarios.cs @@ -5,7 +5,7 @@ using NUnit.Framework; [TestFixture] -public class ReleaseBranchScenarios +public class ReleaseBranchScenarios : TestBase { [Test] public void NoMergeBacksToDevelopInCaseThereAreNoChangesInReleaseBranch() diff --git a/src/GitVersionCore.Tests/IntegrationTests/RemoteRepositoryScenarios.cs b/src/GitVersionCore.Tests/IntegrationTests/RemoteRepositoryScenarios.cs index d6debdcc42..1812a8a475 100644 --- a/src/GitVersionCore.Tests/IntegrationTests/RemoteRepositoryScenarios.cs +++ b/src/GitVersionCore.Tests/IntegrationTests/RemoteRepositoryScenarios.cs @@ -1,14 +1,14 @@ using System; -using System.ComponentModel; using GitTools.Git; using GitTools.Testing; using GitVersionCore.Tests; using LibGit2Sharp; using NUnit.Framework; using Shouldly; +using GitTools; [TestFixture] -public class RemoteRepositoryScenarios +public class RemoteRepositoryScenarios : TestBase { [Test] public void GivenARemoteGitRepositoryWithCommits_ThenClonedLocalShouldMatchRemoteVersion() diff --git a/src/GitVersionCore.Tests/IntegrationTests/SupportBranchScenarios.cs b/src/GitVersionCore.Tests/IntegrationTests/SupportBranchScenarios.cs index 47f4037dee..2684e9b9b6 100644 --- a/src/GitVersionCore.Tests/IntegrationTests/SupportBranchScenarios.cs +++ b/src/GitVersionCore.Tests/IntegrationTests/SupportBranchScenarios.cs @@ -4,7 +4,7 @@ using NUnit.Framework; [TestFixture] -public class SupportBranchScenarios +public class SupportBranchScenarios : TestBase { [Test] public void SupportIsCalculatedCorrectly() diff --git a/src/GitVersionCore.Tests/IntegrationTests/SwitchingToGitFlowScenarios.cs b/src/GitVersionCore.Tests/IntegrationTests/SwitchingToGitFlowScenarios.cs index b26e05ca79..61da2ebfab 100644 --- a/src/GitVersionCore.Tests/IntegrationTests/SwitchingToGitFlowScenarios.cs +++ b/src/GitVersionCore.Tests/IntegrationTests/SwitchingToGitFlowScenarios.cs @@ -4,7 +4,7 @@ using NUnit.Framework; [TestFixture] -public class SwitchingToGitFlowScenarios +public class SwitchingToGitFlowScenarios : TestBase { [Test] public void WhenDevelopBranchedFromMasterWithLegacyVersionTags_DevelopCanUseReachableTag() diff --git a/src/GitVersionCore.Tests/IntegrationTests/VersionBumpingScenarios.cs b/src/GitVersionCore.Tests/IntegrationTests/VersionBumpingScenarios.cs index bc583af524..aad1a5c164 100644 --- a/src/GitVersionCore.Tests/IntegrationTests/VersionBumpingScenarios.cs +++ b/src/GitVersionCore.Tests/IntegrationTests/VersionBumpingScenarios.cs @@ -5,7 +5,7 @@ using System.Collections.Generic; [TestFixture] -public class VersionBumpingScenarios +public class VersionBumpingScenarios : TestBase { [Test] public void AppliedPrereleaseTagCausesBump() diff --git a/src/GitVersionCore.Tests/JsonVersionBuilderTests.cs b/src/GitVersionCore.Tests/JsonVersionBuilderTests.cs index 72989d8a99..cfcc45684d 100644 --- a/src/GitVersionCore.Tests/JsonVersionBuilderTests.cs +++ b/src/GitVersionCore.Tests/JsonVersionBuilderTests.cs @@ -5,7 +5,7 @@ using Shouldly; [TestFixture] -public class JsonVersionBuilderTests +public class JsonVersionBuilderTests : TestBase { [SetUp] public void Setup() diff --git a/src/GitVersionCore.Tests/LoggerTest.cs b/src/GitVersionCore.Tests/LoggerTest.cs index e4f43f33a1..e6d0a77278 100644 --- a/src/GitVersionCore.Tests/LoggerTest.cs +++ b/src/GitVersionCore.Tests/LoggerTest.cs @@ -6,7 +6,7 @@ namespace GitVersionCore.Tests { [TestFixture] - public class LoggerTest + public class LoggerTest : TestBase { [Test] [TestCase("http")] diff --git a/src/GitVersionCore.Tests/Mocks/MockQueryableCommitLog.cs b/src/GitVersionCore.Tests/Mocks/MockQueryableCommitLog.cs index d9241619b7..b8a57127ba 100644 --- a/src/GitVersionCore.Tests/Mocks/MockQueryableCommitLog.cs +++ b/src/GitVersionCore.Tests/Mocks/MockQueryableCommitLog.cs @@ -36,14 +36,7 @@ public IEnumerable QueryBy(string path) { throw new NotImplementedException(); } - -#pragma warning disable CS0618 // Type or member is obsolete - public IEnumerable QueryBy(string path, FollowFilter filter) -#pragma warning restore CS0618 // Type or member is obsolete - { - throw new NotImplementedException(); - } - + public Commit FindMergeBase(Commit first, Commit second) { return null; diff --git a/src/GitVersionCore.Tests/Mocks/MockThreadSleep.cs b/src/GitVersionCore.Tests/Mocks/MockThreadSleep.cs index e32b4f5e04..fa04ecf06e 100644 --- a/src/GitVersionCore.Tests/Mocks/MockThreadSleep.cs +++ b/src/GitVersionCore.Tests/Mocks/MockThreadSleep.cs @@ -1,20 +1,21 @@ using System; using GitVersion.Helpers; +using System.Threading.Tasks; public class MockThreadSleep : IThreadSleep { - private Action Validator; - - public MockThreadSleep(Action validator = null) + private Func Validator; + + public MockThreadSleep(Func validator = null) { this.Validator = validator; } - public void Sleep(int milliseconds) + public async Task SleepAsync(int milliseconds) { if (Validator != null) { - Validator(milliseconds); + await Validator(milliseconds); } } } diff --git a/src/GitVersionCore.Tests/OperationWithExponentialBackoffTests.cs b/src/GitVersionCore.Tests/OperationWithExponentialBackoffTests.cs index 0e8ad200fd..9f1b84634f 100644 --- a/src/GitVersionCore.Tests/OperationWithExponentialBackoffTests.cs +++ b/src/GitVersionCore.Tests/OperationWithExponentialBackoffTests.cs @@ -3,9 +3,11 @@ using GitVersion.Helpers; using NUnit.Framework; using Shouldly; +using System.Threading.Tasks; +using GitVersionCore.Tests; [TestFixture] -public class OperationWithExponentialBackoffTests +public class OperationWithExponentialBackoffTests : TestBase { [Test] public void RetryOperationThrowsWhenNegativeMaxRetries() @@ -22,7 +24,7 @@ public void RetryOperationThrowsWhenThreadSleepIsNull() } [Test] - public void OperationIsNotRetriedOnInvalidException() + public async Task OperationIsNotRetriedOnInvalidException() { Action operation = () => { @@ -30,12 +32,12 @@ public void OperationIsNotRetriedOnInvalidException() }; var retryOperation = new OperationWithExponentialBackoff(new MockThreadSleep(), operation); - Action action = () => retryOperation.Execute(); - action.ShouldThrow(); + Task action = retryOperation.ExecuteAsync(); + await action.ShouldThrowAsync(); } [Test] - public void OperationIsRetriedOnIOException() + public async Task OperationIsRetriedOnIOException() { var operationCount = 0; @@ -49,13 +51,13 @@ public void OperationIsRetriedOnIOException() }; var retryOperation = new OperationWithExponentialBackoff(new MockThreadSleep(), operation); - retryOperation.Execute(); + await retryOperation.ExecuteAsync(); operationCount.ShouldBe(2); } [Test] - public void OperationIsRetriedAMaximumNumberOfTimes() + public async Task OperationIsRetriedAMaximumNumberOfTimesAsync() { const int numberOfRetries = 3; var operationCount = 0; @@ -67,14 +69,14 @@ public void OperationIsRetriedAMaximumNumberOfTimes() }; var retryOperation = new OperationWithExponentialBackoff(new MockThreadSleep(), operation, numberOfRetries); - Action action = () => retryOperation.Execute(); - action.ShouldThrow(); + Task action = retryOperation.ExecuteAsync(); + await action.ShouldThrowAsync(); operationCount.ShouldBe(numberOfRetries + 1); } [Test] - public void OperationDelayDoublesBetweenRetries() + public async Task OperationDelayDoublesBetweenRetries() { const int numberOfRetries = 3; var expectedSleepMSec = 500; @@ -85,22 +87,28 @@ public void OperationDelayDoublesBetweenRetries() throw new IOException(); }; - Action validator = u => + Func validator = (u) => { - sleepCount++; - u.ShouldBe(expectedSleepMSec); - expectedSleepMSec *= 2; + return Task.Run(() => + { + sleepCount++; + u.ShouldBe(expectedSleepMSec); + expectedSleepMSec *= 2; + }); + }; var retryOperation = new OperationWithExponentialBackoff(new MockThreadSleep(validator), operation, numberOfRetries); - Action action = () => retryOperation.Execute(); - action.ShouldThrow(); + Task action = retryOperation.ExecuteAsync(); + await action.ShouldThrowAsync(); + + // action.ShouldThrow(); sleepCount.ShouldBe(numberOfRetries); } [Test] - public void TotalSleepTimeForSixRetriesIsAboutThirtySeconds() + public async Task TotalSleepTimeForSixRetriesIsAboutThirtySecondsAsync() { const int numberOfRetries = 6; int totalSleep = 0; @@ -110,14 +118,21 @@ public void TotalSleepTimeForSixRetriesIsAboutThirtySeconds() throw new IOException(); }; - Action validator = u => + Func validator = (u) => { - totalSleep += u; + return Task.Run(() => + { + totalSleep += u; + }); + }; var retryOperation = new OperationWithExponentialBackoff(new MockThreadSleep(validator), operation, numberOfRetries); - Action action = () => retryOperation.Execute(); - action.ShouldThrow(); + + Task action = retryOperation.ExecuteAsync(); + await action.ShouldThrowAsync(); + // Action action = () => retryOperation.ExecuteAsync(); + // action.ShouldThrow(); // Exact number is 31,5 seconds totalSleep.ShouldBe(31500); diff --git a/src/GitVersionCore.Tests/SemanticVersionTests.cs b/src/GitVersionCore.Tests/SemanticVersionTests.cs index 498d91c998..a44cb3e04c 100644 --- a/src/GitVersionCore.Tests/SemanticVersionTests.cs +++ b/src/GitVersionCore.Tests/SemanticVersionTests.cs @@ -1,9 +1,10 @@ using GitVersion; +using GitVersionCore.Tests; using NUnit.Framework; using Shouldly; [TestFixture] -public class SemanticVersionTests +public class SemanticVersionTests : TestBase { [TestCase("1.2.3", 1, 2, 3, null, null, null, null, null, null, null, null)] diff --git a/src/GitVersionCore.Tests/TestBase.cs b/src/GitVersionCore.Tests/TestBase.cs new file mode 100644 index 0000000000..53381cf9cc --- /dev/null +++ b/src/GitVersionCore.Tests/TestBase.cs @@ -0,0 +1,11 @@ +namespace GitVersionCore.Tests +{ + public class TestBase + { + static TestBase() + { + ModuleInitializer.Initialize(); + } + + } +} diff --git a/src/GitVersionCore.Tests/VariableProviderTests.cs b/src/GitVersionCore.Tests/VariableProviderTests.cs index cebf0d6862..f8bdf1f895 100644 --- a/src/GitVersionCore.Tests/VariableProviderTests.cs +++ b/src/GitVersionCore.Tests/VariableProviderTests.cs @@ -5,8 +5,9 @@ using Shouldly; [TestFixture] -public class VariableProviderTests -{ +public class VariableProviderTests : TestBase +{ + [SetUp] public void Setup() { diff --git a/src/GitVersionCore.Tests/VersionCalculation/BaseVersionCalculatorTests.cs b/src/GitVersionCore.Tests/VersionCalculation/BaseVersionCalculatorTests.cs index 7a7057b058..dd53f77941 100644 --- a/src/GitVersionCore.Tests/VersionCalculation/BaseVersionCalculatorTests.cs +++ b/src/GitVersionCore.Tests/VersionCalculation/BaseVersionCalculatorTests.cs @@ -12,7 +12,7 @@ using Shouldly; [TestFixture] - public class BaseVersionCalculatorTests + public class BaseVersionCalculatorTests : TestBase { [Test] public void ChoosesHighestVersionReturnedFromStrategies() diff --git a/src/GitVersionCore.Tests/VersionCalculation/NextVersionCalculatorTests.cs b/src/GitVersionCore.Tests/VersionCalculation/NextVersionCalculatorTests.cs index b3b947b796..aade87827e 100644 --- a/src/GitVersionCore.Tests/VersionCalculation/NextVersionCalculatorTests.cs +++ b/src/GitVersionCore.Tests/VersionCalculation/NextVersionCalculatorTests.cs @@ -10,7 +10,7 @@ using NUnit.Framework; using Shouldly; - public class NextVersionCalculatorTests + public class NextVersionCalculatorTests : TestBase { [Test] public void ShouldIncrementVersionBasedOnConfig() diff --git a/src/GitVersionCore.Tests/VersionCalculation/Strategies/ConfigNextVersionBaseVersionStrategyTests.cs b/src/GitVersionCore.Tests/VersionCalculation/Strategies/ConfigNextVersionBaseVersionStrategyTests.cs index 1938c10d3d..e0a6f8e6cd 100644 --- a/src/GitVersionCore.Tests/VersionCalculation/Strategies/ConfigNextVersionBaseVersionStrategyTests.cs +++ b/src/GitVersionCore.Tests/VersionCalculation/Strategies/ConfigNextVersionBaseVersionStrategyTests.cs @@ -7,7 +7,7 @@ using Shouldly; [TestFixture] - public class ConfigNextVersionBaseVersionStrategyTests + public class ConfigNextVersionBaseVersionStrategyTests : TestBase { [Test] public void ShouldNotBeIncremented() diff --git a/src/GitVersionCore.Tests/VersionCalculation/Strategies/MergeMessageBaseVersionStrategyTests.cs b/src/GitVersionCore.Tests/VersionCalculation/Strategies/MergeMessageBaseVersionStrategyTests.cs index 18d0892aaa..407940265a 100644 --- a/src/GitVersionCore.Tests/VersionCalculation/Strategies/MergeMessageBaseVersionStrategyTests.cs +++ b/src/GitVersionCore.Tests/VersionCalculation/Strategies/MergeMessageBaseVersionStrategyTests.cs @@ -8,7 +8,7 @@ using Shouldly; [TestFixture] - public class MergeMessageBaseVersionStrategyTests + public class MergeMessageBaseVersionStrategyTests : TestBase { [Test] public void ShouldNotAllowIncrementOfVersion() diff --git a/src/GitVersionCore.Tests/VersionCalculation/Strategies/VersionInBranchNameBaseVersionStrategyTests.cs b/src/GitVersionCore.Tests/VersionCalculation/Strategies/VersionInBranchNameBaseVersionStrategyTests.cs index 01afaa0ea8..106d729260 100644 --- a/src/GitVersionCore.Tests/VersionCalculation/Strategies/VersionInBranchNameBaseVersionStrategyTests.cs +++ b/src/GitVersionCore.Tests/VersionCalculation/Strategies/VersionInBranchNameBaseVersionStrategyTests.cs @@ -9,7 +9,7 @@ using Shouldly; [TestFixture] - public class VersionInBranchNameBaseVersionStrategyTests + public class VersionInBranchNameBaseVersionStrategyTests : TestBase { [Test] [TestCase("release-2.0.0", "2.0.0")] diff --git a/src/GitVersionCore.Tests/VersionFilters/MinDateVersionFilterTests.cs b/src/GitVersionCore.Tests/VersionFilters/MinDateVersionFilterTests.cs index 6733c8ad28..a10dda8adf 100644 --- a/src/GitVersionCore.Tests/VersionFilters/MinDateVersionFilterTests.cs +++ b/src/GitVersionCore.Tests/VersionFilters/MinDateVersionFilterTests.cs @@ -8,7 +8,7 @@ namespace GitVersionCore.Tests.VersionFilters { [TestFixture] - public class MinDateVersionFilterTests + public class MinDateVersionFilterTests : TestBase { [Test] public void VerifyNullGuard() diff --git a/src/GitVersionCore.Tests/VersionFilters/ShaVersionFilterTests.cs b/src/GitVersionCore.Tests/VersionFilters/ShaVersionFilterTests.cs index 9374fa7b0b..ce36271a4f 100644 --- a/src/GitVersionCore.Tests/VersionFilters/ShaVersionFilterTests.cs +++ b/src/GitVersionCore.Tests/VersionFilters/ShaVersionFilterTests.cs @@ -8,7 +8,7 @@ namespace GitVersionCore.Tests.VersionFilters { [TestFixture] - public class ShaVersionFilterTests + public class ShaVersionFilterTests : TestBase { [Test] public void VerifyNullGuard() diff --git a/src/GitVersionCore.Tests/app.config b/src/GitVersionCore.Tests/app.config index c24557fb8a..97f26416bc 100644 --- a/src/GitVersionCore.Tests/app.config +++ b/src/GitVersionCore.Tests/app.config @@ -1,15 +1,13 @@ - + - - - - - - - + + + - \ No newline at end of file + + + diff --git a/src/GitVersionCore.Tests/packages.config b/src/GitVersionCore.Tests/packages.config deleted file mode 100644 index 0797568c38..0000000000 --- a/src/GitVersionCore.Tests/packages.config +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/GitVersionCore/AssemblyInfo.cs b/src/GitVersionCore/AssemblyInfo.cs index e99b097fdb..b4a21bb9ee 100644 --- a/src/GitVersionCore/AssemblyInfo.cs +++ b/src/GitVersionCore/AssemblyInfo.cs @@ -10,4 +10,4 @@ [assembly: InternalsVisibleTo("GitVersionCore.Tests")] [assembly: InternalsVisibleTo("GitVersionExe.Tests")] -[assembly: AssemblyInformationalVersion("4.0.0-beta.12+1291.Branch.master.Sha.bc74ac2247d8a58053a33316334ada6b771a8455")] +[assembly: AssemblyInformationalVersion("4.0.0-netstandard.1+1538.Branch.feature/netstandard.Sha.91536c107ba91f755f14904fc69965a9ad70fcb0")] diff --git a/src/GitVersionCore/BuildServers/AppVeyor.cs b/src/GitVersionCore/BuildServers/AppVeyor.cs index 619f6d81e2..c430d6ab27 100644 --- a/src/GitVersionCore/BuildServers/AppVeyor.cs +++ b/src/GitVersionCore/BuildServers/AppVeyor.cs @@ -3,6 +3,13 @@ using System; using System.Net; using System.Text; +#if !NETDESKTOP + using System.Net.Http; + using System.Threading.Tasks; + using System.Net.Http.Headers; + using Newtonsoft.Json; + using System.IO; +#endif public class AppVeyor : BuildServerBase { @@ -13,6 +20,97 @@ public override bool CanApplyToCurrentContext() return !string.IsNullOrEmpty(Environment.GetEnvironmentVariable(EnvironmentVariableName)); } +#if !NETDESKTOP + + + public override string GenerateSetVersionMessage(VersionVariables variables) + { + + var buildNumber = Environment.GetEnvironmentVariable("APPVEYOR_BUILD_NUMBER"); + var restBase = Environment.GetEnvironmentVariable("APPVEYOR_API_URL"); + + var request = (HttpWebRequest)WebRequest.Create(restBase + "api/build"); + request.Method = "PUT"; + + + var data = string.Format("{{ \"version\": \"{0}.build.{1}\" }}", variables.FullSemVer, buildNumber); + var bytes = Encoding.UTF8.GetBytes(data); + if (request.Headers == null) + { + request.Headers = new WebHeaderCollection(); + } + + var bytesLength = bytes.Length; + //request.Headers["Content-Length"] = bytesLength.ToString(); + // request.ContentLength = bytes.Length; + request.ContentType = "application/json"; + + using (var writeStream = request.GetRequestStreamAsync().Result) + { + writeStream.Write(bytes, 0, bytes.Length); + } + + //var result = request.BeginGetRequestStream((asyncResult) => + // { + // using (var writeStream = request.EndGetRequestStream(asyncResult)) + // { + // writeStream.Write(bytes, 0, bytes.Length); + // } + + // }, null); + + // result.AsyncWaitHandle.WaitOne(new TimeSpan(0, 3, 0)); + + using (var response = (HttpWebResponse)request.GetResponseAsync().Result) + { + if (response.StatusCode != HttpStatusCode.OK && response.StatusCode != HttpStatusCode.NoContent) + { + var message = string.Format("Request failed. Received HTTP {0}", response.StatusCode); + return message; + } + } + + return string.Format("Set AppVeyor build number to '{0}'.", variables.FullSemVer); + + } + + + public override string[] GenerateSetParameterMessage(string name, string value) + { + + // var buildNumber = Environment.GetEnvironmentVariable("APPVEYOR_BUILD_NUMBER"); + var restBase = Environment.GetEnvironmentVariable("APPVEYOR_API_URL"); + + var request = (HttpWebRequest)WebRequest.Create(restBase + "api/build/variables"); + request.Method = "POST"; + request.ContentType = "application/json"; + request.Accept = "application/json"; + + var data = string.Format("{{ \"name\": \"GitVersion_{0}\", \"value\": \"{1}\" }}", name, value); + var bytes = Encoding.UTF8.GetBytes(data); + if (request.Headers == null) + { + request.Headers = new WebHeaderCollection(); + } + var bytesLength = bytes.Length; + // No property for content-length - and no Add() method on header collection? WHAAAAT + // request.ContentLength = bytes.Length; + //request.Headers["Content-Length"] = bytesLength.ToString(); + + using (var writeStream = request.GetRequestStreamAsync().Result) + { + writeStream.Write(bytes, 0, bytes.Length); + } + + return new[] + { + string.Format("Adding Environment Variable. name='GitVersion_{0}' value='{1}']", name, value) + }; + } + + +#else + public override string GenerateSetVersionMessage(VersionVariables variables) { var buildNumber = Environment.GetEnvironmentVariable("APPVEYOR_BUILD_NUMBER"); @@ -23,7 +121,14 @@ public override string GenerateSetVersionMessage(VersionVariables variables) var data = string.Format("{{ \"version\": \"{0}.build.{1}\" }}", variables.FullSemVer, buildNumber); var bytes = Encoding.UTF8.GetBytes(data); - request.ContentLength = bytes.Length; + if (request.Headers == null) + { + request.Headers = new WebHeaderCollection(); + } + var bytesLength = bytes.Length; + // request.Headers["Content-Length"] = bytesLength.ToString(); + + // request.ContentLength = bytes.Length; request.ContentType = "application/json"; using (var writeStream = request.GetRequestStream()) @@ -60,5 +165,9 @@ public override string[] GenerateSetParameterMessage(string name, string value) string.Format("Adding Environment Variable. name='GitVersion_{0}' value='{1}']", name, value) }; } + + +#endif + } } \ No newline at end of file diff --git a/src/GitVersionCore/BuildServers/BuildServerList.cs b/src/GitVersionCore/BuildServers/BuildServerList.cs index dcd4f6f5a8..87751cbbf4 100644 --- a/src/GitVersionCore/BuildServers/BuildServerList.cs +++ b/src/GitVersionCore/BuildServers/BuildServerList.cs @@ -7,7 +7,9 @@ public static class BuildServerList { static List BuildServers = new List { +#if NETDESKTOP new ContinuaCi(), +#endif new TeamCity(), new AppVeyor(), new MyGet(), diff --git a/src/GitVersionCore/BuildServers/MyGet.cs b/src/GitVersionCore/BuildServers/MyGet.cs index 7f652ebc9e..fe7a6b9453 100644 --- a/src/GitVersionCore/BuildServers/MyGet.cs +++ b/src/GitVersionCore/BuildServers/MyGet.cs @@ -10,7 +10,7 @@ public override bool CanApplyToCurrentContext() var buildRunner = Environment.GetEnvironmentVariable("BuildRunner"); return !string.IsNullOrEmpty(buildRunner) - && buildRunner.Equals("MyGet", StringComparison.InvariantCultureIgnoreCase); + && buildRunner.Equals("MyGet", StringComparerUtils.IngoreCaseComparison); } public override string[] GenerateSetParameterMessage(string name, string value) @@ -20,7 +20,7 @@ public override string[] GenerateSetParameterMessage(string name, string value) string.Format("##myget[setParameter name='GitVersion.{0}' value='{1}']", name, ServiceMessageEscapeHelper.EscapeValue(value)) }; - if (string.Equals(name, "LegacySemVerPadded", StringComparison.InvariantCultureIgnoreCase)) + if (string.Equals(name, "LegacySemVerPadded", StringComparerUtils.IngoreCaseComparison)) { messages.Add(string.Format("##myget[buildNumber '{0}']", ServiceMessageEscapeHelper.EscapeValue(value))); } diff --git a/src/GitVersionCore/Configuration/Config.cs b/src/GitVersionCore/Configuration/Config.cs index 733b294292..8225df969f 100644 --- a/src/GitVersionCore/Configuration/Config.cs +++ b/src/GitVersionCore/Configuration/Config.cs @@ -4,6 +4,7 @@ using System.Collections.Generic; using System.Globalization; using System.Linq; + using System.Reflection; using System.Text.RegularExpressions; using YamlDotNet.Serialization; diff --git a/src/GitVersionCore/Configuration/ConfigurationProvider.cs b/src/GitVersionCore/Configuration/ConfigurationProvider.cs index 6c78f4b037..d0fc3b8d96 100644 --- a/src/GitVersionCore/Configuration/ConfigurationProvider.cs +++ b/src/GitVersionCore/Configuration/ConfigurationProvider.cs @@ -6,7 +6,7 @@ namespace GitVersion using System.IO; using System.Linq; using System.Text; - using WarningException = System.ComponentModel.WarningException; + using WarningException = GitTools.WarningException; public class ConfigurationProvider { diff --git a/src/GitVersionCore/Configuration/LegacyConfig.cs b/src/GitVersionCore/Configuration/LegacyConfig.cs index 69d83a7a8f..abc46debd3 100644 --- a/src/GitVersionCore/Configuration/LegacyConfig.cs +++ b/src/GitVersionCore/Configuration/LegacyConfig.cs @@ -3,6 +3,7 @@ namespace GitVersion using System.Collections.Generic; using System.Linq; using YamlDotNet.Serialization; + using System.Reflection; /// /// Obsolete properties are added to this, so we can check to see if they are used and provide good error messages for migration @@ -42,7 +43,9 @@ public Dictionary Branches private T MergeObjects(T target, T source) { - typeof(T).GetProperties() + + var typeInfo = typeof(T); + typeInfo.GetProperties() .Where(prop => prop.CanRead && prop.CanWrite) .Select(_ => new { diff --git a/src/GitVersionCore/Configuration/TypeHelper.cs b/src/GitVersionCore/Configuration/TypeHelper.cs new file mode 100644 index 0000000000..b94e68f8b0 --- /dev/null +++ b/src/GitVersionCore/Configuration/TypeHelper.cs @@ -0,0 +1,30 @@ +using System; +using System.Collections.Generic; +using System.Reflection; + +//public static class TypeHelper +//{ +//#if NETDESKTOP +// public static Type GetType() +// { +// return GetType(); +// } +//#else +// public static TypeInfo GetType() +// { +// return GetType(); +// } +//#endif + +//#if NETDESKTOP +// public static IEnumerable GetConstructorsForType() +// { +// return GetType().GetConstructors(); +// } +//#else +// public static IEnumerable GetConstructorsForType() +// { +// return GetType().DeclaredConstructors; +// } +//#endif +//} diff --git a/src/GitVersionCore/ExecuteCore.cs b/src/GitVersionCore/ExecuteCore.cs index edb5de640f..1080721420 100644 --- a/src/GitVersionCore/ExecuteCore.cs +++ b/src/GitVersionCore/ExecuteCore.cs @@ -1,10 +1,12 @@ namespace GitVersion { + using GitTools; using GitVersion.Helpers; using LibGit2Sharp; using System; using System.ComponentModel; using System.Linq; + using System.Threading.Tasks; public class ExecuteCore { @@ -61,7 +63,7 @@ public VersionVariables ExecuteGitVersion(string targetUrl, string dynamicReposi { try { - gitVersionCache.WriteVariablesToDiskCache(gitPreparer, cacheKey, versionVariables); + gitVersionCache.WriteVariablesToDiskCache(gitPreparer, cacheKey, versionVariables); } catch (AggregateException e) { @@ -124,7 +126,7 @@ IRepository GetRepository(string gitDirectory) var branch = repository.Head; if (branch.Tip == null) { - throw new WarningException("No Tip found. Has repo been initialized?"); + throw new GitTools.WarningException("No Tip found. Has repo been initialized?"); } return repository; } @@ -132,7 +134,7 @@ IRepository GetRepository(string gitDirectory) { if (exception.Message.Contains("LibGit2Sharp.Core.NativeMethods") || exception.Message.Contains("FilePathMarshaler")) { - throw new WarningException("Restart of the process may be required to load an updated version of LibGit2Sharp."); + throw new GitTools.WarningException("Restart of the process may be required to load an updated version of LibGit2Sharp."); } throw; } diff --git a/src/GitVersionCore/Extensions/ReadEmbeddedResourceExtensions.cs b/src/GitVersionCore/Extensions/ReadEmbeddedResourceExtensions.cs index a57e7ef720..4f5ff14587 100644 --- a/src/GitVersionCore/Extensions/ReadEmbeddedResourceExtensions.cs +++ b/src/GitVersionCore/Extensions/ReadEmbeddedResourceExtensions.cs @@ -1,6 +1,7 @@ namespace GitVersionCore.Extensions { using System.IO; + using System.Reflection; public static class ReadEmbeddedResourceExtensions { @@ -23,7 +24,11 @@ public static string ReadAsStringFromEmbeddedResource(this string resourceNam public static Stream ReadFromEmbeddedResource(this string resourceName) { +#if NETDESKTOP var assembly = typeof(T).Assembly; +#else + var assembly = typeof(T).GetTypeInfo().Assembly; +#endif return assembly.GetManifestResourceStream(resourceName); } } diff --git a/src/GitVersionCore/Extensions/TaskHelper.cs b/src/GitVersionCore/Extensions/TaskHelper.cs new file mode 100644 index 0000000000..92cffec0b7 --- /dev/null +++ b/src/GitVersionCore/Extensions/TaskHelper.cs @@ -0,0 +1,29 @@ +namespace System.Threading.Tasks +{ + public static class TaskHelper + { + +#if NETDESKTOP + public static Task Delay(int milliseconds) + { + var tcs = new TaskCompletionSource(); + System.Timers.Timer timer = new System.Timers.Timer(); + timer.Elapsed += (obj, args) => + { + tcs.TrySetResult(true); + }; + timer.Interval = (double)milliseconds; + timer.AutoReset = false; + timer.Start(); + return tcs.Task; + } +#else + public static Task Delay(int milliseconds) + { + return Task.Delay(milliseconds); + } +#endif + } + + +} diff --git a/src/GitVersionCore/FodyWeavers.xml b/src/GitVersionCore/FodyWeavers.xml deleted file mode 100644 index 2ca034c764..0000000000 --- a/src/GitVersionCore/FodyWeavers.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/src/GitVersionCore/GitPreparer.cs b/src/GitVersionCore/GitPreparer.cs index 50f0e48de3..919340889f 100644 --- a/src/GitVersionCore/GitPreparer.cs +++ b/src/GitVersionCore/GitPreparer.cs @@ -83,14 +83,14 @@ private void CleanupDuplicateOrigin() var repo = new Repository(GetDotGitDirectory()); // check that we have a remote that matches defaultRemoteName if not take the first remote - if (!repo.Network.Remotes.Any(remote => remote.Name.Equals(defaultRemoteName, StringComparison.InvariantCultureIgnoreCase))) + if (!repo.Network.Remotes.Any(remote => remote.Name.Equals(defaultRemoteName, StringComparerUtils.IngoreCaseComparison))) { remoteToKeep = repo.Network.Remotes.First().Name; } var duplicateRepos = repo.Network .Remotes - .Where(remote => !remote.Name.Equals(remoteToKeep, StringComparison.InvariantCultureIgnoreCase)) + .Where(remote => !remote.Name.Equals(remoteToKeep, StringComparerUtils.IngoreCaseComparison)) .Select(remote => remote.Name); // remove all remotes that are considered duplicates diff --git a/src/GitVersionCore/GitVersionCache.cs b/src/GitVersionCore/GitVersionCache.cs index 99307c2ab6..d7d1783a37 100644 --- a/src/GitVersionCore/GitVersionCache.cs +++ b/src/GitVersionCore/GitVersionCache.cs @@ -5,6 +5,7 @@ namespace GitVersion using System.Collections.Generic; using System.IO; using System.Linq; + using System.Threading.Tasks; using YamlDotNet.Serialization; public class GitVersionCache @@ -45,7 +46,7 @@ public void WriteVariablesToDiskCache(GitPreparer gitPreparer, GitVersionCacheKe }; var retryOperation = new OperationWithExponentialBackoff(new ThreadSleep(), writeCacheOperation, maxRetries: 6); - retryOperation.Execute(); + retryOperation.ExecuteAsync().Wait(); } public static string GetCacheDirectory(GitPreparer gitPreparer) diff --git a/src/GitVersionCore/GitVersionCore.csproj b/src/GitVersionCore/GitVersionCore.csproj index d95644ffd2..ebb4e6db9a 100644 --- a/src/GitVersionCore/GitVersionCore.csproj +++ b/src/GitVersionCore/GitVersionCore.csproj @@ -1,52 +1,65 @@ - - - - + + - Debug - AnyCPU - {F9741A0D-B9D7-4557-9A1C-A7252C1071F5} + netstandard1.3;net40 Library - Properties GitVersion GitVersionCore - v4.0 - 6 - 512 $(SolutionDir)..\build\ - - + + GitVersionCore + GitVersion + GitTools and Contributors + https://github.com/GitTools/GitVersion + false + Git;Versioning;GitVersion;GitFlowVersion;GitFlow;GitHubFlow;SemVer + Derives SemVer information from a repository following GitFlow or GitHubFlow. + Copyright GitTools 2015. + http://www.opensource.org/licenses/mit-license.php + https://raw.githubusercontent.com/GitTools/GitVersion/master/docs/img/package_icon.png + https://github.com/GitTools/GitVersion/releases + + $(Authors) + $(AssemblyName) + false + false + false + false + false + true - - true + + + TRACE;NET40;NETDESKTOP + + + + TRACE;NETSTANDARD1_3; + + + full false bin\Debug\ DEBUG;TRACE - prompt - 4 bin\Debug\GitVersionCore.xml - 1591 - + + pdbonly true bin\Release\ TRACE - prompt - 4 bin\Release\GitVersionCore.xml - 1591 - - - - ..\packages\GitTools.Core.1.2.1-beta0001\lib\net4\GitTools.Core.dll - True - - - ..\packages\LibGit2Sharp.0.23.0-pre20160922233542\lib\net40\LibGit2Sharp.dll - True - + + + + + + + + + @@ -54,183 +67,43 @@ - - ..\packages\YamlDotNet.3.8.0\lib\net35\YamlDotNet.dll - True - + + + + All + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + - - - - - - - - - - - - + + + + + - - Designer - Designer - - - - - This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - - - - - - - - - - - - - - - - - - - - - - - - - + \ No newline at end of file diff --git a/src/GitVersionCore/GitVersionFinder.cs b/src/GitVersionCore/GitVersionFinder.cs index 77addc07c1..4cf9d37170 100644 --- a/src/GitVersionCore/GitVersionFinder.cs +++ b/src/GitVersionCore/GitVersionFinder.cs @@ -1,8 +1,8 @@ namespace GitVersion { - using System.ComponentModel; using System.IO; using GitVersion.VersionCalculation; + using GitTools; public class GitVersionFinder { @@ -21,8 +21,8 @@ public SemanticVersion FindVersion(GitVersionContext context) var filePath = Path.Combine(context.Repository.GetRepositoryDirectory(), "NextVersion.txt"); if (File.Exists(filePath)) - { - throw new WarningException("NextVersion.txt has been deprecated. See http://gitversion.readthedocs.org/en/latest/configuration/ for replacement"); + { + throw new GitTools.WarningException("NextVersion.txt has been deprecated. See http://gitversion.readthedocs.org/en/latest/configuration/ for replacement"); } return new NextVersionCalculator().FindVersion(context); diff --git a/src/GitVersionCore/Helpers/EncodingHelper.cs b/src/GitVersionCore/Helpers/EncodingHelper.cs index 392f86e2ac..8337246f67 100644 --- a/src/GitVersionCore/Helpers/EncodingHelper.cs +++ b/src/GitVersionCore/Helpers/EncodingHelper.cs @@ -73,13 +73,30 @@ public static Encoding DetectEncoding(IList bytes) /// An ordered list of encodings and corresponding preambles. private static void ScanEncodings() { - EncodingsWithPreambles = (from info in Encoding.GetEncodings() - let encoding = info.GetEncoding() - let preamble = encoding.GetPreamble() - where preamble.Length > 0 - orderby preamble.Length descending - select encoding).ToList(); - + // Might be out of luck finding a replacement for GetEncodings for netcore 1: https://stackoverflow.com/questions/44351507/what-is-net-core-equivalent-of-encoding-getencodings +#if NETDESKTOP + var encodings = (Encoding.GetEncodings()); + EncodingsWithPreambles = (from info in encodings + let encoding = info.GetEncoding() + let preamble = encoding.GetPreamble() + where preamble.Length > 0 + orderby preamble.Length descending + select encoding).ToList(); + +#else + // GetEncodings not available on netstandard, so just manually adding some common ones. + var encodings = new List() { Encoding.ASCII, Encoding.Unicode, Encoding.UTF32, Encoding.UTF7, Encoding.UTF8 }; + EncodingsWithPreambles = (from info in encodings + let preamble = info.GetPreamble() + where preamble.Length > 0 + orderby preamble.Length descending + select info).ToList(); +#endif + + + + + var encodingWithLongestPreamble = EncodingsWithPreambles.FirstOrDefault(); MaxPreambleLength = encodingWithLongestPreamble == null ? 0 : encodingWithLongestPreamble.GetPreamble().Length; } diff --git a/src/GitVersionCore/Helpers/EnvironmentHelper.cs b/src/GitVersionCore/Helpers/EnvironmentHelper.cs index 84d35afe0d..9c955dae23 100644 --- a/src/GitVersionCore/Helpers/EnvironmentHelper.cs +++ b/src/GitVersionCore/Helpers/EnvironmentHelper.cs @@ -6,7 +6,11 @@ public class EnvironmentHelper { public static string GetEnvironmentVariableForProcess(string envVar) { +#if NETDESKTOP return Environment.GetEnvironmentVariable(envVar, EnvironmentVariableTarget.Process); +#else + return Environment.GetEnvironmentVariable(envVar); +#endif } } } diff --git a/src/GitVersionCore/Helpers/FileSystem.cs b/src/GitVersionCore/Helpers/FileSystem.cs index f3022e816c..551ba0c0f8 100644 --- a/src/GitVersionCore/Helpers/FileSystem.cs +++ b/src/GitVersionCore/Helpers/FileSystem.cs @@ -86,8 +86,8 @@ public long GetLastDirectoryWrite(string path) public bool PathsEqual(string path, string otherPath) { var comparison = runningOnMono - ? StringComparison.InvariantCulture - : StringComparison.InvariantCultureIgnoreCase; + ? StringComparerUtils.CaseSensitiveComparison + : StringComparerUtils.IngoreCaseComparison; return string.Equals( Path.GetFullPath(path).TrimEnd('\\').TrimEnd('/'), diff --git a/src/GitVersionCore/Helpers/IThreadSleep.cs b/src/GitVersionCore/Helpers/IThreadSleep.cs index 86484d3580..ca6f90f302 100644 --- a/src/GitVersionCore/Helpers/IThreadSleep.cs +++ b/src/GitVersionCore/Helpers/IThreadSleep.cs @@ -1,7 +1,9 @@ -namespace GitVersion.Helpers +using System.Threading.Tasks; + +namespace GitVersion.Helpers { public interface IThreadSleep { - void Sleep(int milliseconds); + Task SleepAsync(int milliseconds); } } diff --git a/src/GitVersionCore/Helpers/OperationWithExponentialBackoff.cs b/src/GitVersionCore/Helpers/OperationWithExponentialBackoff.cs index 61e6e6fd73..56e48cc5a3 100644 --- a/src/GitVersionCore/Helpers/OperationWithExponentialBackoff.cs +++ b/src/GitVersionCore/Helpers/OperationWithExponentialBackoff.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Threading.Tasks; namespace GitVersion.Helpers { @@ -21,7 +22,7 @@ public OperationWithExponentialBackoff(IThreadSleep threadSleep, Action operatio this.MaxRetries = maxRetries; } - public void Execute() + public async Task ExecuteAsync() { var exceptions = new List(); @@ -47,7 +48,8 @@ public void Execute() } Logger.WriteInfo(string.Format("Operation failed, retrying in {0} milliseconds.", sleepMSec)); - ThreadSleep.Sleep(sleepMSec); + await ThreadSleep.SleepAsync(sleepMSec); + sleepMSec *= 2; } } diff --git a/src/GitVersionCore/Helpers/ThreadSleep.cs b/src/GitVersionCore/Helpers/ThreadSleep.cs index b20989814e..f293358199 100644 --- a/src/GitVersionCore/Helpers/ThreadSleep.cs +++ b/src/GitVersionCore/Helpers/ThreadSleep.cs @@ -1,12 +1,12 @@ namespace GitVersion.Helpers { - using System.Threading; + using System.Threading.Tasks; internal class ThreadSleep : IThreadSleep { - public void Sleep(int milliseconds) + public async Task SleepAsync(int milliseconds) { - Thread.Sleep(milliseconds); + await TaskHelper.Delay(milliseconds); } } } diff --git a/src/GitVersionCore/OutputVariables/VariableProvider.cs b/src/GitVersionCore/OutputVariables/VariableProvider.cs index 5781041b9e..007bfc670c 100644 --- a/src/GitVersionCore/OutputVariables/VariableProvider.cs +++ b/src/GitVersionCore/OutputVariables/VariableProvider.cs @@ -1,9 +1,9 @@ namespace GitVersion { using System; - using System.ComponentModel; using System.Text.RegularExpressions; using GitVersion.VersionCalculation; + using WarningException = GitTools.WarningException; public static class VariableProvider { diff --git a/src/GitVersionCore/OutputVariables/VersionVariables.cs b/src/GitVersionCore/OutputVariables/VersionVariables.cs index 430736187a..d5c4ec0d2e 100644 --- a/src/GitVersionCore/OutputVariables/VersionVariables.cs +++ b/src/GitVersionCore/OutputVariables/VersionVariables.cs @@ -6,6 +6,8 @@ using System.IO; using System.Linq; using GitVersion.Helpers; + using System.Reflection; + using YamlDotNet.Serialization; @@ -116,7 +118,20 @@ public static IEnumerable AvailableVariables [ReflectionIgnore] public string this[string variable] { - get { return (string)typeof(VersionVariables).GetProperty(variable).GetValue(this, null); } + + + get + { +#if NETDESKTOP + return typeof(VersionVariables).GetProperty(variable).GetValue(this, null) as string; +#else + throw new NotImplementedException(); + // return typeof(VersionVariables).GetTypeInfo().GetProperty(variable).GetValue(this, null) as string; +#endif + + + + } } public IEnumerator> GetEnumerator() @@ -137,7 +152,9 @@ IEnumerator IEnumerable.GetEnumerator() public static VersionVariables FromDictionary(IEnumerable> properties) { var type = typeof(VersionVariables); - var ctor = type.GetConstructors().Single(); + var constructors = type.GetConstructors(); + + var ctor = constructors.Single(); var ctorArgs = ctor.GetParameters() .Select(p => properties.Single(v => string.Equals(v.Key, p.Name, StringComparison.CurrentCultureIgnoreCase)).Value) .Cast() @@ -173,7 +190,12 @@ public bool TryGetValue(string variable, out string variableValue) public bool ContainsKey(string variable) { +#if NETDESKTOP return typeof(VersionVariables).GetProperty(variable) != null; +#else + throw new NotImplementedException(); + // return typeof(VersionVariables).GetTypeInfo().GetProperty(variable) != null; +#endif } sealed class ReflectionIgnoreAttribute : Attribute diff --git a/src/GitVersionCore/Properties/PublishProfiles/FolderProfile.pubxml b/src/GitVersionCore/Properties/PublishProfiles/FolderProfile.pubxml new file mode 100644 index 0000000000..54e7a81f71 --- /dev/null +++ b/src/GitVersionCore/Properties/PublishProfiles/FolderProfile.pubxml @@ -0,0 +1,13 @@ + + + + + FileSystem + Release + netstandard1.3 + bin\Release\PublishOutput + + \ No newline at end of file diff --git a/src/GitVersionCore/SearchPath.cs b/src/GitVersionCore/SearchPath.cs index b8f7cbb1d4..1fd9535324 100644 --- a/src/GitVersionCore/SearchPath.cs +++ b/src/GitVersionCore/SearchPath.cs @@ -22,7 +22,17 @@ public static void SetSearchPath(string addinDirectoryPath) static string GetProcessorArchitecture() { - if (Environment.Is64BitProcess) +#if NETDESKTOP + var is64 = Environment.Is64BitProcess; +#else + var arch = System.Runtime.InteropServices.RuntimeInformation.OSArchitecture; + bool is64 = (arch == System.Runtime.InteropServices.Architecture.X64 || arch == System.Runtime.InteropServices.Architecture.Arm64); + if (arch == System.Runtime.InteropServices.Architecture.X64) + { + return "X64"; + } +#endif + if (is64) { return "amd64"; } diff --git a/src/GitVersionCore/SemanticVersion.cs b/src/GitVersionCore/SemanticVersion.cs index e98056d7bd..51927ee959 100644 --- a/src/GitVersionCore/SemanticVersion.cs +++ b/src/GitVersionCore/SemanticVersion.cs @@ -1,5 +1,6 @@ namespace GitVersion { + using GitTools; using System; using System.ComponentModel; using System.Text.RegularExpressions; @@ -141,7 +142,7 @@ public static SemanticVersion Parse(string version, string tagPrefixRegex) { SemanticVersion semanticVersion; if (!TryParse(version, tagPrefixRegex, out semanticVersion)) - throw new WarningException(string.Format("Failed to parse {0} into a Semantic Version", version)); + throw new GitTools.WarningException(string.Format("Failed to parse {0} into a Semantic Version", version)); return semanticVersion; } diff --git a/src/GitVersionCore/SemanticVersionPreReleaseTag.cs b/src/GitVersionCore/SemanticVersionPreReleaseTag.cs index 4a9e57e01d..92e3982633 100644 --- a/src/GitVersionCore/SemanticVersionPreReleaseTag.cs +++ b/src/GitVersionCore/SemanticVersionPreReleaseTag.cs @@ -1,10 +1,11 @@ +using System; +using System.Linq; +using System.Text.RegularExpressions; + namespace GitVersion { - using System; - using System.Linq; - using System.Text.RegularExpressions; - public class SemanticVersionPreReleaseTag : + public class SemanticVersionPreReleaseTag : IFormattable, IComparable, IEquatable { static LambdaEqualityHelper equalityHelper = @@ -71,7 +72,7 @@ public override int GetHashCode() public static bool operator <=(SemanticVersionPreReleaseTag left, SemanticVersionPreReleaseTag right) { - return StringComparer.InvariantCultureIgnoreCase.Compare(left.Name, right.Name) != 1; + return StringComparerUtils.IngoreCaseComparer.Compare(left.Name, right.Name) != 1; } public static implicit operator string(SemanticVersionPreReleaseTag preReleaseTag) @@ -99,7 +100,7 @@ public static SemanticVersionPreReleaseTag Parse(string preReleaseTag) } var value = match.Groups["name"].Value; - var number = match.Groups["number"].Success ? int.Parse(match.Groups["number"].Value) : (int?) null; + var number = match.Groups["number"].Success ? int.Parse(match.Groups["number"].Value) : (int?)null; if (value.EndsWith("-")) return new SemanticVersionPreReleaseTag(preReleaseTag, null); @@ -117,7 +118,8 @@ public int CompareTo(SemanticVersionPreReleaseTag other) return -1; } - var nameComparison = StringComparer.InvariantCultureIgnoreCase.Compare(Name, other.Name); + + var nameComparison = StringComparerUtils.IngoreCaseComparer.Compare(Name, other.Name); if (nameComparison != 0) return nameComparison; diff --git a/src/GitVersionCore/StringComparerUtils.cs b/src/GitVersionCore/StringComparerUtils.cs new file mode 100644 index 0000000000..d61d0ab2fe --- /dev/null +++ b/src/GitVersionCore/StringComparerUtils.cs @@ -0,0 +1,19 @@ +using System; + +namespace GitVersion +{ + public static class StringComparerUtils + { +#if NETDESKTOP + public static readonly System.StringComparer IngoreCaseComparer = StringComparer.InvariantCultureIgnoreCase; + public static readonly StringComparison IngoreCaseComparison = StringComparison.InvariantCultureIgnoreCase; + public static readonly StringComparison CaseSensitiveComparison = StringComparison.InvariantCulture; +#else + public static readonly System.StringComparer IngoreCaseComparer = StringComparer.OrdinalIgnoreCase; + public static readonly StringComparison IngoreCaseComparison = StringComparison.OrdinalIgnoreCase; + public static readonly StringComparison CaseSensitiveComparison = StringComparison.Ordinal; +#endif + } + + +} diff --git a/src/GitVersionCore/StringFormatWith.cs b/src/GitVersionCore/StringFormatWith.cs index 693eb5b814..f10232b033 100644 --- a/src/GitVersionCore/StringFormatWith.cs +++ b/src/GitVersionCore/StringFormatWith.cs @@ -85,12 +85,12 @@ static Func CompileDataBinder(Type type, string expr) { body = Expression.PropertyOrField(body, members[i]); } - var method = typeof(Convert).GetMethod("ToString", BindingFlags.Static | BindingFlags.Public, - null, new Type[] { body.Type }, null); + + var staticOrPublic = BindingFlags.Static | BindingFlags.Public; + var method = GetMethodInfo("ToString", staticOrPublic, new Type[] { body.Type }); if (method == null) { - method = typeof(Convert).GetMethod("ToString", BindingFlags.Static | BindingFlags.Public, - null, new Type[] { typeof(object) }, null); + method = GetMethodInfo("ToString", staticOrPublic, new Type[] { typeof(object) }); body = Expression.Call(method, Expression.Convert(body, typeof(object))); } else @@ -100,5 +100,18 @@ static Func CompileDataBinder(Type type, string expr) return Expression.Lambda>(body, param).Compile(); } + + private static MethodInfo GetMethodInfo(string name, BindingFlags bindingFlags, Type[] types) + { +#if NETDESKTOP + var methodInfo = typeof(Convert).GetMethod(name, bindingFlags, null, types, null); + return methodInfo; +#else + var type = typeof(Convert); + var methodInfo = typeof(Convert).GetMethod(name, types); + return methodInfo; +#endif + //throw new NotImplementedException(); + } } } \ No newline at end of file diff --git a/src/GitVersionCore/TemplateManager.cs b/src/GitVersionCore/TemplateManager.cs index 4a1ff4ae6c..2613dc282d 100644 --- a/src/GitVersionCore/TemplateManager.cs +++ b/src/GitVersionCore/TemplateManager.cs @@ -5,6 +5,7 @@ using System.IO; using System.Linq; using GitVersionCore.Extensions; + using System.Reflection; enum TemplateType { @@ -71,7 +72,15 @@ public bool IsSupported(string fileExtension) static IEnumerable GetEmbeddedTemplates(TemplateType templateType, string templateCategory) { - foreach (var name in typeof(TemplateManager).Assembly.GetManifestResourceNames()) + + Assembly assy = null; +#if NETDESKTOP + assy = typeof(TemplateManager).Assembly; +#else + assy = typeof(TemplateManager).GetTypeInfo().Assembly; +#endif + + foreach (var name in assy.GetManifestResourceNames()) { if (name.Contains(templateType.ToString()) && name.Contains(templateCategory)) { diff --git a/src/GitVersionCore/app.config b/src/GitVersionCore/app.config index b57ccf84c3..5fafb00cde 100644 --- a/src/GitVersionCore/app.config +++ b/src/GitVersionCore/app.config @@ -1,11 +1,5 @@  - - - - - - - + \ No newline at end of file diff --git a/src/GitVersionCore/packages.config b/src/GitVersionCore/packages.config deleted file mode 100644 index 34b78fd67b..0000000000 --- a/src/GitVersionCore/packages.config +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/src/GitVersionExe.Tests/GitVersionExe.Tests.csproj b/src/GitVersionExe.Tests/GitVersionExe.Tests.csproj index 35845d9e0f..d2a5c3aa2a 100644 --- a/src/GitVersionExe.Tests/GitVersionExe.Tests.csproj +++ b/src/GitVersionExe.Tests/GitVersionExe.Tests.csproj @@ -1,21 +1,23 @@ - - - - + Debug AnyCPU - {75C2BE85-1DAF-4E34-8305-B17AFAA982A6} + Library - Properties + GitVersionExe.Tests GitVersionExe.Tests - v4.5 - 512 - 6 - - + net461 + + false + false + false + false + false + true + + true full @@ -35,48 +37,21 @@ true - - ..\packages\GitTools.Core.1.2.1-beta0001\lib\net45\GitTools.Core.dll - True - - - ..\packages\GitTools.Testing.1.1.1-beta0001\lib\net4\GitTools.Testing.dll - True - - - ..\packages\LibGit2Sharp.0.23.0-pre20160922233542\lib\net40\LibGit2Sharp.dll - True - - - ..\packages\Mono.Cecil.0.9.6.4\lib\net45\Mono.Cecil.dll - True - - - ..\packages\Mono.Cecil.0.9.6.4\lib\net45\Mono.Cecil.Mdb.dll - True - - - ..\packages\Mono.Cecil.0.9.6.4\lib\net45\Mono.Cecil.Pdb.dll - True - - - ..\packages\Mono.Cecil.0.9.6.4\lib\net45\Mono.Cecil.Rocks.dll - True - - - ..\packages\NSubstitute.1.10.0.0\lib\net45\NSubstitute.dll - True - - - ..\packages\NUnit.3.6.0\lib\net45\nunit.framework.dll - True - - - ..\packages\Shouldly.2.7.0\lib\net40\Shouldly.dll - True - + + + + + + + + + + + + + @@ -84,53 +59,19 @@ - - - {BF905F84-382C-440D-92F5-C61108626D8D} - GitVersionCore.Tests - - - {F9741A0D-B9D7-4557-9A1C-A7252C1071F5} - GitVersionCore - - - {c3578a7b-09a6-4444-9383-0deafa4958bd} - GitVersionExe - + + + - - Designer - - - - - - - - - - - - - - - - - - - - - - - This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - + + + + \ No newline at end of file diff --git a/src/GitVersionExe.Tests/Helpers/DirectoryHelper.cs b/src/GitVersionExe.Tests/Helpers/DirectoryHelper.cs new file mode 100644 index 0000000000..0b34a20605 --- /dev/null +++ b/src/GitVersionExe.Tests/Helpers/DirectoryHelper.cs @@ -0,0 +1,84 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; + +public static class DirectoryHelper +{ + static Dictionary toRename = new Dictionary + { + {"gitted", ".git"}, + {"gitmodules", ".gitmodules"}, + }; + + public static void CopyFilesRecursively(DirectoryInfo source, DirectoryInfo target) + { + // From http://stackoverflow.com/questions/58744/best-way-to-copy-the-entire-contents-of-a-directory-in-c/58779#58779 + + foreach (var dir in source.GetDirectories()) + { + CopyFilesRecursively(dir, target.CreateSubdirectory(Rename(dir.Name))); + } + foreach (var file in source.GetFiles()) + { + file.CopyTo(Path.Combine(target.FullName, Rename(file.Name))); + } + } + + static string Rename(string name) + { + return toRename.ContainsKey(name) ? toRename[name] : name; + } + + public static void DeleteSubDirectories(string parentPath) + { + var dirs = Directory.GetDirectories(parentPath); + foreach (var dir in dirs) + { + DeleteDirectory(dir); + } + } + + public static void DeleteDirectory(string directoryPath) + { + // From http://stackoverflow.com/questions/329355/cannot-delete-directory-with-directory-deletepath-true/329502#329502 + + if (!Directory.Exists(directoryPath)) + { + Trace.WriteLine( + string.Format("Directory '{0}' is missing and can't be removed.", + directoryPath)); + + return; + } + + var files = Directory.GetFiles(directoryPath); + var dirs = Directory.GetDirectories(directoryPath); + + foreach (var file in files) + { + File.SetAttributes(file, FileAttributes.Normal); + File.Delete(file); + } + + foreach (var dir in dirs) + { + DeleteDirectory(dir); + } + + File.SetAttributes(directoryPath, FileAttributes.Normal); + try + { + Directory.Delete(directoryPath, false); + } + catch (IOException) + { + Trace.WriteLine(string.Format("{0}The directory '{1}' could not be deleted!" + + "{0}Most of the time, this is due to an external process accessing the files in the temporary repositories created during the test runs, and keeping a handle on the directory, thus preventing the deletion of those files." + + "{0}Known and common causes include:" + + "{0}- Windows Search Indexer (go to the Indexing Options, in the Windows Control Panel, and exclude the bin folder of LibGit2Sharp.Tests)" + + "{0}- Antivirus (exclude the bin folder of LibGit2Sharp.Tests from the paths scanned by your real-time antivirus){0}", + Environment.NewLine, Path.GetFullPath(directoryPath))); + } + } +} \ No newline at end of file diff --git a/src/GitVersionExe.Tests/Helpers/PathHelper.cs b/src/GitVersionExe.Tests/Helpers/PathHelper.cs new file mode 100644 index 0000000000..b73edfeda1 --- /dev/null +++ b/src/GitVersionExe.Tests/Helpers/PathHelper.cs @@ -0,0 +1,16 @@ +using System; +using System.IO; +using System.Reflection; + +public static class PathHelper +{ + public static string GetCurrentDirectory() + { + return Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); + } + + public static string GetTempPath() + { + return Path.Combine(GetCurrentDirectory(), "TestRepositories", Guid.NewGuid().ToString()); + } +} \ No newline at end of file diff --git a/src/GitVersionExe.Tests/Helpers/TestFileSystem.cs b/src/GitVersionExe.Tests/Helpers/TestFileSystem.cs new file mode 100644 index 0000000000..217957b015 --- /dev/null +++ b/src/GitVersionExe.Tests/Helpers/TestFileSystem.cs @@ -0,0 +1,115 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Text; + +using GitVersion.Helpers; + +public class TestFileSystem : IFileSystem +{ + Dictionary fileSystem = new Dictionary(); + + public void Copy(string @from, string to, bool overwrite) + { + if (fileSystem.ContainsKey(to)) + { + if (overwrite) + fileSystem.Remove(to); + else + throw new IOException("File already exists"); + } + + byte[] source; + if (!fileSystem.TryGetValue(from, out source)) + throw new FileNotFoundException(string.Format("The source file '{0}' was not found", from), from); + + fileSystem.Add(to, source); + } + + public void Move(string @from, string to) + { + Copy(from, to, false); + fileSystem.Remove(from); + } + + public bool Exists(string file) + { + return fileSystem.ContainsKey(file); + } + + public void Delete(string path) + { + fileSystem.Remove(path); + } + + public string ReadAllText(string path) + { + byte[] content; + if (!fileSystem.TryGetValue(path, out content)) + throw new FileNotFoundException(string.Format("The file '{0}' was not found", path), path); + + var encoding = EncodingHelper.DetectEncoding(content) ?? Encoding.UTF8; + return encoding.GetString(content); + } + + public void WriteAllText(string file, string fileContents) + { + var encoding = fileSystem.ContainsKey(file) + ? EncodingHelper.DetectEncoding(fileSystem[file]) ?? Encoding.UTF8 + : Encoding.UTF8; + WriteAllText(file, fileContents, encoding); + } + + public void WriteAllText(string file, string fileContents, Encoding encoding) + { + fileSystem[file] = encoding.GetBytes(fileContents); + } + + public IEnumerable DirectoryGetFiles(string directory, string searchPattern, SearchOption searchOption) + { + throw new NotImplementedException(); + } + + public Stream OpenWrite(string path) + { + return new TestStream(path, this); + } + + public Stream OpenRead(string path) + { + if (fileSystem.ContainsKey(path)) + { + var content = fileSystem[path]; + return new MemoryStream(content); + } + + throw new FileNotFoundException("File not found.", path); + } + + public void CreateDirectory(string path) + { + if (fileSystem.ContainsKey(path)) + { + fileSystem[path] = new byte[0]; + } + else + { + fileSystem.Add(path, new byte[0]); + } + } + + public bool DirectoryExists(string path) + { + return fileSystem.ContainsKey(path); + } + + public long GetLastDirectoryWrite(string path) + { + return 1; + } + + public bool PathsEqual(string path, string otherPath) + { + return path == otherPath; + } +} \ No newline at end of file diff --git a/src/GitVersionExe.Tests/Helpers/TestStream.cs b/src/GitVersionExe.Tests/Helpers/TestStream.cs new file mode 100644 index 0000000000..ce23cfa7ec --- /dev/null +++ b/src/GitVersionExe.Tests/Helpers/TestStream.cs @@ -0,0 +1,76 @@ +using System; +using System.IO; +using System.Threading; +using System.Threading.Tasks; + +public class TestStream : Stream +{ + readonly string path; + readonly TestFileSystem testFileSystem; + MemoryStream underlying = new MemoryStream(); + + public TestStream(string path, TestFileSystem testFileSystem) + { + this.path = path; + this.testFileSystem = testFileSystem; + } + + protected override void Dispose(bool disposing) + { + Flush(); + base.Dispose(disposing); + } + + public override void Flush() + { + underlying.Position = 0; + var readToEnd = new StreamReader(underlying).ReadToEnd(); + testFileSystem.WriteAllText(path, readToEnd); + } + + public override long Seek(long offset, SeekOrigin origin) + { + return underlying.Seek(offset, origin); + } + + public override void SetLength(long value) + { + underlying.SetLength(value); + } + + public override int Read(byte[] buffer, int offset, int count) + { + return underlying.Read(buffer, offset, count); + } + + public override void Write(byte[] buffer, int offset, int count) + { + underlying.Write(buffer, offset, count); + } + + public override void WriteByte(byte value) + { + base.WriteByte(value); + } + + public override IAsyncResult BeginWrite(byte[] buffer, int offset, int count, AsyncCallback callback, object state) + { + return base.BeginWrite(buffer, offset, count, callback, state); + } + + public override Task WriteAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken) + { + return base.WriteAsync(buffer, offset, count, cancellationToken); + } + + public override bool CanRead { get { return underlying.CanRead; } } + public override bool CanSeek { get { return underlying.CanSeek; } } + public override bool CanWrite { get { return underlying.CanWrite; } } + public override long Length { get { return underlying.Length; } } + + public override long Position + { + get { return underlying.Position; } + set { underlying.Position = value; } + } +} \ No newline at end of file diff --git a/src/GitVersionExe.Tests/TestEffectiveConfiguration.cs b/src/GitVersionExe.Tests/TestEffectiveConfiguration.cs new file mode 100644 index 0000000000..6b2d03ddfe --- /dev/null +++ b/src/GitVersionExe.Tests/TestEffectiveConfiguration.cs @@ -0,0 +1,48 @@ +namespace GitVersionExe.Tests +{ + using GitVersion; + using GitVersion.VersionFilters; + using System.Collections.Generic; + using System.Linq; + + public class TestEffectiveConfiguration : EffectiveConfiguration + { + public TestEffectiveConfiguration( + AssemblyVersioningScheme assemblyVersioningScheme = AssemblyVersioningScheme.MajorMinorPatch, + AssemblyFileVersioningScheme assemblyFileVersioningScheme = AssemblyFileVersioningScheme.MajorMinorPatch, + string assemblyVersioningFormat = null, + string assemblyFileVersioningFormat = null, + string assemblyInformationalFormat = null, + VersioningMode versioningMode = VersioningMode.ContinuousDelivery, + string gitTagPrefix = "v", + string tag = "", + string nextVersion = null, + string branchPrefixToTrim = "", + bool preventIncrementForMergedBranchVersion = false, + string tagNumberPattern = null, + string continuousDeploymentFallbackTag = "ci", + bool trackMergeTarget = false, + string majorMessage = null, + string minorMessage = null, + string patchMessage = null, + string noBumpMessage = null, + CommitMessageIncrementMode commitMessageMode = CommitMessageIncrementMode.Enabled, + int legacySemVerPadding = 4, + int buildMetaDataPadding = 4, + int commitsSinceVersionSourcePadding = 4, + IEnumerable versionFilters = null, + bool tracksReleaseBranches = false, + bool isRelease = false, + string commitDateFormat = "yyyy-MM-dd") : + base(assemblyVersioningScheme, assemblyFileVersioningScheme, assemblyInformationalFormat, assemblyVersioningFormat, assemblyFileVersioningFormat, versioningMode, gitTagPrefix, tag, nextVersion, IncrementStrategy.Patch, + branchPrefixToTrim, preventIncrementForMergedBranchVersion, tagNumberPattern, continuousDeploymentFallbackTag, + trackMergeTarget, + majorMessage, minorMessage, patchMessage, noBumpMessage, + commitMessageMode, legacySemVerPadding, buildMetaDataPadding, commitsSinceVersionSourcePadding, + versionFilters ?? Enumerable.Empty(), + tracksReleaseBranches, isRelease, commitDateFormat) + + { + } + } +} \ No newline at end of file diff --git a/src/GitVersionExe.Tests/app.config b/src/GitVersionExe.Tests/app.config index c24557fb8a..2f21c15a6d 100644 --- a/src/GitVersionExe.Tests/app.config +++ b/src/GitVersionExe.Tests/app.config @@ -1,15 +1,15 @@ - + - - + + - - + + - \ No newline at end of file + diff --git a/src/GitVersionExe.Tests/packages.config b/src/GitVersionExe.Tests/packages.config deleted file mode 100644 index 30641d4d15..0000000000 --- a/src/GitVersionExe.Tests/packages.config +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - \ No newline at end of file diff --git a/src/GitVersionExe/ArgumentParser.cs b/src/GitVersionExe/ArgumentParser.cs index 3323686a3c..a4fec8f437 100644 --- a/src/GitVersionExe/ArgumentParser.cs +++ b/src/GitVersionExe/ArgumentParser.cs @@ -128,6 +128,7 @@ public static Arguments ParseArguments(List commandLineArguments) continue; } +#if NETDESKTOP if (name.IsSwitch("exec")) { EnsureArgumentValueCount(values); @@ -135,6 +136,7 @@ public static Arguments ParseArguments(List commandLineArguments) continue; } + if (name.IsSwitch("execargs")) { EnsureArgumentValueCount(values); @@ -166,6 +168,8 @@ public static Arguments ParseArguments(List commandLineArguments) continue; } +#endif + if (name.IsSwitch("updateAssemblyInfo")) { diff --git a/src/GitVersionExe/Arguments.cs b/src/GitVersionExe/Arguments.cs index 910ee131e2..ad21176a46 100644 --- a/src/GitVersionExe/Arguments.cs +++ b/src/GitVersionExe/Arguments.cs @@ -26,20 +26,21 @@ public Arguments() public string DynamicRepositoryLocation; public bool Init; +#if NETDESKTOP public bool Diag; - +#endif public bool IsVersion; public bool IsHelp; public string LogFilePath; public string ShowVariable; public OutputType Output; - +#if NETDESKTOP public string Proj; public string ProjArgs; public string Exec; public string ExecArgs; - +#endif public bool UpdateAssemblyInfo; public ISet UpdateAssemblyInfoFileName; public bool EnsureAssemblyInfo; diff --git a/src/GitVersionExe/AssemblyInfo.cs b/src/GitVersionExe/AssemblyInfo.cs index 10f78a2e2a..8830673801 100644 --- a/src/GitVersionExe/AssemblyInfo.cs +++ b/src/GitVersionExe/AssemblyInfo.cs @@ -9,4 +9,4 @@ [assembly: InternalsVisibleTo("AcceptanceTests")] [assembly: InternalsVisibleTo("GitVersionExe.Tests")] -[assembly: AssemblyInformationalVersion("4.0.0-beta.12+1291.Branch.master.Sha.bc74ac2247d8a58053a33316334ada6b771a8455")] +[assembly: AssemblyInformationalVersion("4.0.0-netstandard.1+1538.Branch.feature/netstandard.Sha.91536c107ba91f755f14904fc69965a9ad70fcb0")] diff --git a/src/GitVersionExe/FodyWeavers.xml b/src/GitVersionExe/FodyWeavers.xml deleted file mode 100644 index ba2f99a4d5..0000000000 --- a/src/GitVersionExe/FodyWeavers.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/src/GitVersionExe/GitVersionExe.csproj b/src/GitVersionExe/GitVersionExe.csproj index 1e6850f761..96ad53b903 100644 --- a/src/GitVersionExe/GitVersionExe.csproj +++ b/src/GitVersionExe/GitVersionExe.csproj @@ -1,31 +1,29 @@ - - - + Debug AnyCPU - 8.0.30703 - 2.0 - {C3578A7B-09A6-4444-9383-0DEAFA4958BD} + Exe GitVersion GitVersion - v4.0 - 6 - 512 + net40;netcoreapp20 $(SolutionDir)..\build\ - - + + false + false + false + false + false + true + true full false bin\Debug\ DEBUG;TRACE - prompt - 4 - false + bin\Debug\GitVersion.xml 1591 @@ -34,37 +32,31 @@ true bin\Release\ TRACE - prompt - 4 - false + bin\Release\GitVersion.xml 1591 + AnyCPU - - - ..\packages\GitTools.Core.1.2.1-beta0001\lib\net4\GitTools.Core.dll - True - - - ..\packages\LibGit2Sharp.0.23.0-pre20160922233542\lib\net40\LibGit2Sharp.dll - True - + + + NET40;NETDESKTOP + + + + + + + + + + - - - - - - - - - - + @@ -85,23 +77,15 @@ - - Designer - - - - Designer - - + + + - - {f9741a0d-b9d7-4557-9a1c-a7252c1071f5} - GitVersionCore - + - + @@ -129,7 +113,6 @@ - mono @@ -141,29 +124,7 @@ - - - - - - - - - - - - - - - - - - - - - - - + @@ -206,14 +167,5 @@ - - - This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - - - - - + \ No newline at end of file diff --git a/src/GitVersionExe/HelpWriter.cs b/src/GitVersionExe/HelpWriter.cs index 6dc97a5de9..ca2f4161d2 100644 --- a/src/GitVersionExe/HelpWriter.cs +++ b/src/GitVersionExe/HelpWriter.cs @@ -16,6 +16,7 @@ public static void WriteTo(Action writeAction) Assembly assembly = Assembly.GetExecutingAssembly(); VersionWriter.WriteTo(assembly, v => version = v); + string message = "GitVersion " + version + @" Use convention to derive a SemVer product version from a GitFlow or GitHub based repository. @@ -37,7 +38,7 @@ path The directory containing .git. If not defined current directory Currently supported config overrides: tag-prefix /nocache Bypasses the cache, result will not be written to the cache. - # AssemblyInfo updating + # AssemblyInfo updating /updateassemblyinfo Will recursively search for all 'AssemblyInfo.cs' files in the git repo and update them /updateassemblyinfofilename @@ -47,7 +48,7 @@ Specify name of AssemblyInfo file. Can also /updateAssemblyInfo GlobalAssemblyIn it be created with these attributes: AssemblyFileVersion, AssemblyVersion and AssemblyInformationalVersion --- Supports writing version info for: C#, F#, VB - # Remote repository args +# Remote repository args /url Url to remote git repository. /b Name of the branch to use on the remote repository, must be used in combination with /url. /u Username in case authentication is required. @@ -57,7 +58,7 @@ Specify name of AssemblyInfo file. Can also /updateAssemblyInfo GlobalAssemblyIn By default dynamic repositories will be cloned to %tmp%. Use this switch to override /nofetch Disables 'git fetch' during version calculation. Might cause GitVersion to not calculate your version as expected. - # Execute build args +# Execute build args /exec Executes target executable making GitVersion variables available as environmental variables /execargs Arguments for the executable specified by /exec /proj Build a msbuild file, GitVersion variables will be passed as msbuild properties @@ -68,6 +69,7 @@ Specify name of AssemblyInfo file. Can also /updateAssemblyInfo GlobalAssemblyIn gitversion init Configuration utility for gitversion "; + writeAction(message); } } diff --git a/src/GitVersionExe/NugetAssets/GitVersion.CommandLine.DotNetCore.nuspec b/src/GitVersionExe/NugetAssets/GitVersion.CommandLine.DotNetCore.nuspec new file mode 100644 index 0000000000..bd1bc66925 --- /dev/null +++ b/src/GitVersionExe/NugetAssets/GitVersion.CommandLine.DotNetCore.nuspec @@ -0,0 +1,19 @@ + + + + GitVersion.CommandLine.DotNetCore + $version$ + GitVersion.CommandLine.DotNetCore + GitTools and Contributors + GitTools and Contributors + http://www.opensource.org/licenses/mit-license.php + https://github.com/GitTools/GitVersion + https://raw.githubusercontent.com/GitTools/GitVersion/master/docs/img/package_icon.png + false + Derives SemVer information from a repository following GitFlow or GitHubFlow. + en-AU + Git Versioning GitVersion GitFlowVersion GitFlow GitHubFlow SemVer + true + https://github.com/GitTools/GitVersion/releases + + diff --git a/src/GitVersionExe/Program.cs b/src/GitVersionExe/Program.cs index efa7db3beb..540d71d24f 100644 --- a/src/GitVersionExe/Program.cs +++ b/src/GitVersionExe/Program.cs @@ -70,19 +70,23 @@ static int VerifyArgumentsAndRun() HelpWriter.Write(); return 0; } +#if NETDESKTOP if (arguments.Diag) { arguments.NoCache = true; arguments.Output = OutputType.BuildServer; - } + } +#endif ConfigureLogging(arguments); +#if NETDESKTOP if (arguments.Diag) { Logger.WriteInfo("Dumping commit graph: "); GitTools.LibGitExtensions.DumpGraph(arguments.TargetPath, Logger.WriteInfo, 100); } +#endif if (!Directory.Exists(arguments.TargetPath)) { Logger.WriteWarning(string.Format("The working directory '{0}' does not exist.", arguments.TargetPath)); @@ -104,11 +108,12 @@ static int VerifyArgumentsAndRun() return 0; } +#if NETDESKTOP if (!string.IsNullOrEmpty(arguments.Proj) || !string.IsNullOrEmpty(arguments.Exec)) { arguments.Output = OutputType.BuildServer; } - +#endif SpecifiedArgumentRunner.Run(arguments, fileSystem); } catch (WarningException exception) @@ -130,7 +135,9 @@ static int VerifyArgumentsAndRun() try { +#if NETDESKTOP GitTools.LibGitExtensions.DumpGraph(arguments.TargetPath, Logger.WriteInfo, 100); +#endif } catch (Exception dumpGraphException) { diff --git a/src/GitVersionExe/SpecifiedArgumentRunner.cs b/src/GitVersionExe/SpecifiedArgumentRunner.cs index 2f585fef62..b4876b2022 100644 --- a/src/GitVersionExe/SpecifiedArgumentRunner.cs +++ b/src/GitVersionExe/SpecifiedArgumentRunner.cs @@ -62,9 +62,12 @@ public static void Run(Arguments arguments, IFileSystem fileSystem) { assemblyInfoUpdater.Update(); } - - var execRun = RunExecCommandIfNeeded(arguments, targetPath, variables); - var msbuildRun = RunMsBuildIfNeeded(arguments, targetPath, variables); + var execRun = false; + var msbuildRun = false; +#if NETDESKTOP + execRun = RunExecCommandIfNeeded(arguments, targetPath, variables); + msbuildRun = RunMsBuildIfNeeded(arguments, targetPath, variables); +#endif if (!execRun && !msbuildRun) { assemblyInfoUpdater.CommitChanges(); @@ -79,8 +82,11 @@ public static void Run(Arguments arguments, IFileSystem fileSystem) } } +#if NETDESKTOP static bool RunMsBuildIfNeeded(Arguments args, string workingDirectory, VersionVariables variables) { + + if (string.IsNullOrEmpty(args.Proj)) return false; Logger.WriteInfo(string.Format("Launching build tool {0} \"{1}\" {2}", BuildTool, args.Proj, args.ProjArgs)); @@ -95,6 +101,7 @@ static bool RunMsBuildIfNeeded(Arguments args, string workingDirectory, VersionV return true; } + static bool RunExecCommandIfNeeded(Arguments args, string workingDirectory, VersionVariables variables) { if (string.IsNullOrEmpty(args.Exec)) return false; @@ -111,6 +118,8 @@ static bool RunExecCommandIfNeeded(Arguments args, string workingDirectory, Vers return true; } +#endif + static KeyValuePair[] GetEnvironmentalVariables(VersionVariables variables) { return variables diff --git a/src/GitVersionExe/app.config b/src/GitVersionExe/app.config index b57ccf84c3..87ccfc557c 100644 --- a/src/GitVersionExe/app.config +++ b/src/GitVersionExe/app.config @@ -4,7 +4,7 @@ - + diff --git a/src/GitVersionExe/packages.config b/src/GitVersionExe/packages.config deleted file mode 100644 index 62114fb516..0000000000 --- a/src/GitVersionExe/packages.config +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/src/GitVersionTask.Tests/FodyWeavers.xml b/src/GitVersionTask.Tests/FodyWeavers.xml deleted file mode 100644 index dbbeecb671..0000000000 --- a/src/GitVersionTask.Tests/FodyWeavers.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/src/GitVersionTask.Tests/GetVersionTaskTests.cs b/src/GitVersionTask.Tests/GetVersionTaskTests.cs index 0030d56da0..a3f6d5c7d1 100644 --- a/src/GitVersionTask.Tests/GetVersionTaskTests.cs +++ b/src/GitVersionTask.Tests/GetVersionTaskTests.cs @@ -6,7 +6,7 @@ using Shouldly; [TestFixture] -public class GetVersionTaskTests +public class GetVersionTaskTests : TestBase { [Test] public void OutputsShouldMatchVariableProvider() diff --git a/src/GitVersionTask.Tests/GitVersionTask.Tests.csproj b/src/GitVersionTask.Tests/GitVersionTask.Tests.csproj index 609219d570..b58c15326f 100644 --- a/src/GitVersionTask.Tests/GitVersionTask.Tests.csproj +++ b/src/GitVersionTask.Tests/GitVersionTask.Tests.csproj @@ -1,22 +1,19 @@ - - - + Debug AnyCPU - 8.0.30703 - 2.0 - {5A86453B-96FB-4B6E-A283-225BB9F753D3} Library - Properties GitVersionTask.Tests GitVersionTask.Tests - v4.5 - 6 - 512 - - - + net461 + + false + false + false + false + false + true + true @@ -40,90 +37,53 @@ true - - ..\packages\FluentDateTime.1.13.0\lib\NET35\FluentDateTime.dll - True - - - ..\packages\GitTools.Core.1.2.1-beta0001\lib\net45\GitTools.Core.dll - True - - - ..\packages\LibGit2Sharp.0.23.0-pre20160922233542\lib\net40\LibGit2Sharp.dll - True - - - + + + + + + + + + + + + + + + + + + + - - ..\packages\NSubstitute.1.10.0.0\lib\net45\NSubstitute.dll - True - - - ..\packages\NUnit.3.6.0\lib\net45\nunit.framework.dll - True - - - ..\packages\Shouldly.2.7.0\lib\net40\Shouldly.dll - True - + - - - - - - - - - - - - + - - Designer - - + + - - - {BF905F84-382C-440D-92F5-C61108626D8D} - GitVersionCore.Tests - - - {F9741A0D-B9D7-4557-9A1C-A7252C1071F5} - GitVersionCore - + - {F7AC0E71-3E9A-4F6D-B986-E004825A48E1} - GitVersionTask - - - + + - - - This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - - - + \ No newline at end of file diff --git a/src/GitVersionTask.Tests/GitVersionTaskDirectoryTests.cs b/src/GitVersionTask.Tests/GitVersionTaskDirectoryTests.cs index 9ba0c96cfc..c928e6735f 100644 --- a/src/GitVersionTask.Tests/GitVersionTaskDirectoryTests.cs +++ b/src/GitVersionTask.Tests/GitVersionTaskDirectoryTests.cs @@ -8,7 +8,7 @@ using NUnit.Framework; [TestFixture] -public class GitVersionTaskDirectoryTests +public class GitVersionTaskDirectoryTests : TestBase { ExecuteCore executeCore; string gitDirectory; diff --git a/src/GitVersionTask.Tests/Helpers/DirectoryHelper.cs b/src/GitVersionTask.Tests/Helpers/DirectoryHelper.cs new file mode 100644 index 0000000000..0b34a20605 --- /dev/null +++ b/src/GitVersionTask.Tests/Helpers/DirectoryHelper.cs @@ -0,0 +1,84 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; + +public static class DirectoryHelper +{ + static Dictionary toRename = new Dictionary + { + {"gitted", ".git"}, + {"gitmodules", ".gitmodules"}, + }; + + public static void CopyFilesRecursively(DirectoryInfo source, DirectoryInfo target) + { + // From http://stackoverflow.com/questions/58744/best-way-to-copy-the-entire-contents-of-a-directory-in-c/58779#58779 + + foreach (var dir in source.GetDirectories()) + { + CopyFilesRecursively(dir, target.CreateSubdirectory(Rename(dir.Name))); + } + foreach (var file in source.GetFiles()) + { + file.CopyTo(Path.Combine(target.FullName, Rename(file.Name))); + } + } + + static string Rename(string name) + { + return toRename.ContainsKey(name) ? toRename[name] : name; + } + + public static void DeleteSubDirectories(string parentPath) + { + var dirs = Directory.GetDirectories(parentPath); + foreach (var dir in dirs) + { + DeleteDirectory(dir); + } + } + + public static void DeleteDirectory(string directoryPath) + { + // From http://stackoverflow.com/questions/329355/cannot-delete-directory-with-directory-deletepath-true/329502#329502 + + if (!Directory.Exists(directoryPath)) + { + Trace.WriteLine( + string.Format("Directory '{0}' is missing and can't be removed.", + directoryPath)); + + return; + } + + var files = Directory.GetFiles(directoryPath); + var dirs = Directory.GetDirectories(directoryPath); + + foreach (var file in files) + { + File.SetAttributes(file, FileAttributes.Normal); + File.Delete(file); + } + + foreach (var dir in dirs) + { + DeleteDirectory(dir); + } + + File.SetAttributes(directoryPath, FileAttributes.Normal); + try + { + Directory.Delete(directoryPath, false); + } + catch (IOException) + { + Trace.WriteLine(string.Format("{0}The directory '{1}' could not be deleted!" + + "{0}Most of the time, this is due to an external process accessing the files in the temporary repositories created during the test runs, and keeping a handle on the directory, thus preventing the deletion of those files." + + "{0}Known and common causes include:" + + "{0}- Windows Search Indexer (go to the Indexing Options, in the Windows Control Panel, and exclude the bin folder of LibGit2Sharp.Tests)" + + "{0}- Antivirus (exclude the bin folder of LibGit2Sharp.Tests from the paths scanned by your real-time antivirus){0}", + Environment.NewLine, Path.GetFullPath(directoryPath))); + } + } +} \ No newline at end of file diff --git a/src/GitVersionTask.Tests/Helpers/PathHelper.cs b/src/GitVersionTask.Tests/Helpers/PathHelper.cs new file mode 100644 index 0000000000..b73edfeda1 --- /dev/null +++ b/src/GitVersionTask.Tests/Helpers/PathHelper.cs @@ -0,0 +1,16 @@ +using System; +using System.IO; +using System.Reflection; + +public static class PathHelper +{ + public static string GetCurrentDirectory() + { + return Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); + } + + public static string GetTempPath() + { + return Path.Combine(GetCurrentDirectory(), "TestRepositories", Guid.NewGuid().ToString()); + } +} \ No newline at end of file diff --git a/src/GitVersionTask.Tests/Helpers/TestEffectiveConfiguration.cs b/src/GitVersionTask.Tests/Helpers/TestEffectiveConfiguration.cs new file mode 100644 index 0000000000..876de76ac1 --- /dev/null +++ b/src/GitVersionTask.Tests/Helpers/TestEffectiveConfiguration.cs @@ -0,0 +1,47 @@ +namespace GitVersionCore.Tests +{ + using GitVersion; + using GitVersion.VersionFilters; + using System.Collections.Generic; + using System.Linq; + + public class TestEffectiveConfiguration : EffectiveConfiguration + { + public TestEffectiveConfiguration( + AssemblyVersioningScheme assemblyVersioningScheme = AssemblyVersioningScheme.MajorMinorPatch, + AssemblyFileVersioningScheme assemblyFileVersioningScheme = AssemblyFileVersioningScheme.MajorMinorPatch, + string assemblyVersioningFormat = null, + string assemblyFileVersioningFormat = null, + string assemblyInformationalFormat = null, + VersioningMode versioningMode = VersioningMode.ContinuousDelivery, + string gitTagPrefix = "v", + string tag = "", + string nextVersion = null, + string branchPrefixToTrim = "", + bool preventIncrementForMergedBranchVersion = false, + string tagNumberPattern = null, + string continuousDeploymentFallbackTag = "ci", + bool trackMergeTarget = false, + string majorMessage = null, + string minorMessage = null, + string patchMessage = null, + string noBumpMessage = null, + CommitMessageIncrementMode commitMessageMode = CommitMessageIncrementMode.Enabled, + int legacySemVerPadding = 4, + int buildMetaDataPadding = 4, + int commitsSinceVersionSourcePadding = 4, + IEnumerable versionFilters = null, + bool tracksReleaseBranches = false, + bool isRelease = false, + string commitDateFormat = "yyyy-MM-dd") : + base(assemblyVersioningScheme, assemblyFileVersioningScheme, assemblyInformationalFormat, assemblyVersioningFormat, assemblyFileVersioningFormat, versioningMode, gitTagPrefix, tag, nextVersion, IncrementStrategy.Patch, + branchPrefixToTrim, preventIncrementForMergedBranchVersion, tagNumberPattern, continuousDeploymentFallbackTag, + trackMergeTarget, + majorMessage, minorMessage, patchMessage, noBumpMessage, + commitMessageMode, legacySemVerPadding, buildMetaDataPadding, commitsSinceVersionSourcePadding, + versionFilters ?? Enumerable.Empty(), + tracksReleaseBranches, isRelease, commitDateFormat) + { + } + } +} \ No newline at end of file diff --git a/src/GitVersionTask.Tests/Helpers/TestFileSystem.cs b/src/GitVersionTask.Tests/Helpers/TestFileSystem.cs new file mode 100644 index 0000000000..217957b015 --- /dev/null +++ b/src/GitVersionTask.Tests/Helpers/TestFileSystem.cs @@ -0,0 +1,115 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Text; + +using GitVersion.Helpers; + +public class TestFileSystem : IFileSystem +{ + Dictionary fileSystem = new Dictionary(); + + public void Copy(string @from, string to, bool overwrite) + { + if (fileSystem.ContainsKey(to)) + { + if (overwrite) + fileSystem.Remove(to); + else + throw new IOException("File already exists"); + } + + byte[] source; + if (!fileSystem.TryGetValue(from, out source)) + throw new FileNotFoundException(string.Format("The source file '{0}' was not found", from), from); + + fileSystem.Add(to, source); + } + + public void Move(string @from, string to) + { + Copy(from, to, false); + fileSystem.Remove(from); + } + + public bool Exists(string file) + { + return fileSystem.ContainsKey(file); + } + + public void Delete(string path) + { + fileSystem.Remove(path); + } + + public string ReadAllText(string path) + { + byte[] content; + if (!fileSystem.TryGetValue(path, out content)) + throw new FileNotFoundException(string.Format("The file '{0}' was not found", path), path); + + var encoding = EncodingHelper.DetectEncoding(content) ?? Encoding.UTF8; + return encoding.GetString(content); + } + + public void WriteAllText(string file, string fileContents) + { + var encoding = fileSystem.ContainsKey(file) + ? EncodingHelper.DetectEncoding(fileSystem[file]) ?? Encoding.UTF8 + : Encoding.UTF8; + WriteAllText(file, fileContents, encoding); + } + + public void WriteAllText(string file, string fileContents, Encoding encoding) + { + fileSystem[file] = encoding.GetBytes(fileContents); + } + + public IEnumerable DirectoryGetFiles(string directory, string searchPattern, SearchOption searchOption) + { + throw new NotImplementedException(); + } + + public Stream OpenWrite(string path) + { + return new TestStream(path, this); + } + + public Stream OpenRead(string path) + { + if (fileSystem.ContainsKey(path)) + { + var content = fileSystem[path]; + return new MemoryStream(content); + } + + throw new FileNotFoundException("File not found.", path); + } + + public void CreateDirectory(string path) + { + if (fileSystem.ContainsKey(path)) + { + fileSystem[path] = new byte[0]; + } + else + { + fileSystem.Add(path, new byte[0]); + } + } + + public bool DirectoryExists(string path) + { + return fileSystem.ContainsKey(path); + } + + public long GetLastDirectoryWrite(string path) + { + return 1; + } + + public bool PathsEqual(string path, string otherPath) + { + return path == otherPath; + } +} \ No newline at end of file diff --git a/src/GitVersionTask.Tests/Helpers/TestStream.cs b/src/GitVersionTask.Tests/Helpers/TestStream.cs new file mode 100644 index 0000000000..ce23cfa7ec --- /dev/null +++ b/src/GitVersionTask.Tests/Helpers/TestStream.cs @@ -0,0 +1,76 @@ +using System; +using System.IO; +using System.Threading; +using System.Threading.Tasks; + +public class TestStream : Stream +{ + readonly string path; + readonly TestFileSystem testFileSystem; + MemoryStream underlying = new MemoryStream(); + + public TestStream(string path, TestFileSystem testFileSystem) + { + this.path = path; + this.testFileSystem = testFileSystem; + } + + protected override void Dispose(bool disposing) + { + Flush(); + base.Dispose(disposing); + } + + public override void Flush() + { + underlying.Position = 0; + var readToEnd = new StreamReader(underlying).ReadToEnd(); + testFileSystem.WriteAllText(path, readToEnd); + } + + public override long Seek(long offset, SeekOrigin origin) + { + return underlying.Seek(offset, origin); + } + + public override void SetLength(long value) + { + underlying.SetLength(value); + } + + public override int Read(byte[] buffer, int offset, int count) + { + return underlying.Read(buffer, offset, count); + } + + public override void Write(byte[] buffer, int offset, int count) + { + underlying.Write(buffer, offset, count); + } + + public override void WriteByte(byte value) + { + base.WriteByte(value); + } + + public override IAsyncResult BeginWrite(byte[] buffer, int offset, int count, AsyncCallback callback, object state) + { + return base.BeginWrite(buffer, offset, count, callback, state); + } + + public override Task WriteAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken) + { + return base.WriteAsync(buffer, offset, count, cancellationToken); + } + + public override bool CanRead { get { return underlying.CanRead; } } + public override bool CanSeek { get { return underlying.CanSeek; } } + public override bool CanWrite { get { return underlying.CanWrite; } } + public override long Length { get { return underlying.Length; } } + + public override long Position + { + get { return underlying.Position; } + set { underlying.Position = value; } + } +} \ No newline at end of file diff --git a/src/GitVersionTask.Tests/InvalidFileCheckerTests.cs b/src/GitVersionTask.Tests/InvalidFileCheckerTests.cs index bf562a329d..d22afabd61 100644 --- a/src/GitVersionTask.Tests/InvalidFileCheckerTests.cs +++ b/src/GitVersionTask.Tests/InvalidFileCheckerTests.cs @@ -1,12 +1,12 @@ using System; -using System.ComponentModel; using System.IO; using GitVersionTask.Tests.Mocks; using Microsoft.Build.Framework; using NUnit.Framework; +using GitTools; [TestFixture] -public class InvalidFileCheckerTests +public class InvalidFileCheckerTests : TestBase { string projectDirectory; string projectFile; diff --git a/src/GitVersionTask.Tests/TestBase.cs b/src/GitVersionTask.Tests/TestBase.cs new file mode 100644 index 0000000000..2d183c187f --- /dev/null +++ b/src/GitVersionTask.Tests/TestBase.cs @@ -0,0 +1,9 @@ +public class TestBase +{ + static TestBase() + { + ModuleInitializer.Initialize(); + } + +} + diff --git a/src/GitVersionTask.Tests/app.config b/src/GitVersionTask.Tests/app.config index 3d12e16fad..c39d7cb3ce 100644 --- a/src/GitVersionTask.Tests/app.config +++ b/src/GitVersionTask.Tests/app.config @@ -16,7 +16,7 @@ - + diff --git a/src/GitVersionTask.Tests/packages.config b/src/GitVersionTask.Tests/packages.config index ea2a6b4fc9..07302cf6d8 100644 --- a/src/GitVersionTask.Tests/packages.config +++ b/src/GitVersionTask.Tests/packages.config @@ -2,12 +2,30 @@ - - - + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/GitVersionTask/AssemblyInfo.cs b/src/GitVersionTask/AssemblyInfo.cs deleted file mode 100644 index d4fbe64c8f..0000000000 --- a/src/GitVersionTask/AssemblyInfo.cs +++ /dev/null @@ -1,7 +0,0 @@ -using System.Reflection; - -[assembly: AssemblyTitle("GitVersionTask")] -[assembly: AssemblyProduct("GitVersionTask")] -[assembly: AssemblyVersion("4.0.0.0")] -[assembly: AssemblyFileVersion("4.0.0.0")] -[assembly: AssemblyInformationalVersion("4.0.0-beta.12+1291.Branch.master.Sha.bc74ac2247d8a58053a33316334ada6b771a8455")] diff --git a/src/GitVersionTask/FodyWeavers.xml b/src/GitVersionTask/FodyWeavers.xml deleted file mode 100644 index 6c4dacc2ba..0000000000 --- a/src/GitVersionTask/FodyWeavers.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/src/GitVersionTask/GenerateGitVersionInformation.cs b/src/GitVersionTask/GenerateGitVersionInformation.cs index aa863b9e19..8abaa5a97d 100644 --- a/src/GitVersionTask/GenerateGitVersionInformation.cs +++ b/src/GitVersionTask/GenerateGitVersionInformation.cs @@ -6,6 +6,9 @@ using GitVersion; using GitVersion.Helpers; using Microsoft.Build.Framework; + using GitTools; + + public class GenerateGitVersionInformation : GitVersionTaskBase { @@ -41,7 +44,7 @@ public override bool Execute() InnerExecute(); return true; } - catch (WarningException errorException) + catch (GitTools.WarningException errorException) { logger.LogWarning(errorException.Message); return true; diff --git a/src/GitVersionTask/GetVersion.cs b/src/GitVersionTask/GetVersion.cs index c699dd2e0d..cb66e84294 100644 --- a/src/GitVersionTask/GetVersion.cs +++ b/src/GitVersionTask/GetVersion.cs @@ -1,10 +1,11 @@ namespace GitVersionTask { using System; - using System.ComponentModel; using GitVersion; using Microsoft.Build.Framework; + using GitTools; + using System.Reflection; public class GetVersion : GitVersionTaskBase { diff --git a/src/GitVersionTask/GitVersionTask.csproj b/src/GitVersionTask/GitVersionTask.csproj index f994daa49c..6da556cace 100644 --- a/src/GitVersionTask/GitVersionTask.csproj +++ b/src/GitVersionTask/GitVersionTask.csproj @@ -1,56 +1,90 @@  - - - + + + + Debug AnyCPU - {F7AC0E71-3E9A-4F6D-B986-E004825A48E1} Library - Properties GitVersionTask GitVersionTask - v4.0 - 6 - 512 - $(SolutionDir)..\build\ - - + net461;netstandard1.5 + + + GitVersionTask + GitVersionTask + GitTools and Contributors + https://github.com/GitTools/GitVersion + false + Git Versioning GitVersion GitFlowVersion GitFlow GitHubFlow SemVer + Stamps an assembly with git information based on SemVer. + Copyright GitTools 2015. + http://www.opensource.org/licenses/mit-license.php + https://raw.githubusercontent.com/GitTools/GitVersion/master/docs/img/package_icon.png + https://github.com/GitTools/GitVersion/releases + true + build + GitTools and Contributors + + NugetAssets\GitVersionTask.nuspec + 0.0.1-alpha-0001 + version=$(PackageVersion);configuration=$(Configuration);utilpackversion=$(PackageVersion_UtilPackNuGetMSBuild);gittoolscoreversion=$(PackageVersion_GitToolsCore);yamldotnetversion=$(PackageVersion_YamlDotNet) + + + + $(Authors) + $(AssemblyName) + + true + true full false - bin\Debug\ DEBUG;TRACE - prompt - 4 - false 1591 pdbonly true - bin\Release\ TRACE prompt 4 - false 1591 - - ..\packages\GitTools.Core.1.2.1-beta0001\lib\net4\GitTools.Core.dll - True - - - ..\packages\LibGit2Sharp.0.23.0-pre20160922233542\lib\net40\LibGit2Sharp.dll - True - - - - - + + + + + + + + + + build\ + + + + + + All + + + All + + + + + + + @@ -58,93 +92,22 @@ - - ..\packages\YamlDotNet.3.8.0\lib\net35\YamlDotNet.dll - True - - - - - - - - - - - - - - + + - - - - Designer - - - Designer - + + - - Designer - + - - - {f9741a0d-b9d7-4557-9a1c-a7252c1071f5} - GitVersionCore - - - - - - - - - - - - - mono - - - - - - - - - - - - - - - - - - - - - - - - - - This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - - - + + f7ac0e71-3e9a-4f6d-b986-e004825a48e1 + + - + - - - - \ No newline at end of file diff --git a/src/GitVersionTask/InvalidFileChecker.cs b/src/GitVersionTask/InvalidFileChecker.cs index 8717977ece..4f522c9df8 100644 --- a/src/GitVersionTask/InvalidFileChecker.cs +++ b/src/GitVersionTask/InvalidFileChecker.cs @@ -1,10 +1,10 @@ using System; using System.Collections.Generic; -using System.ComponentModel; using System.IO; using System.Linq; using System.Text.RegularExpressions; using Microsoft.Build.Framework; +using GitTools; public static class InvalidFileChecker { diff --git a/src/GitVersionTask/NugetAssets/GitVersionTask.nuspec b/src/GitVersionTask/NugetAssets/GitVersionTask.nuspec index 2e053e86cc..160e456e42 100644 --- a/src/GitVersionTask/NugetAssets/GitVersionTask.nuspec +++ b/src/GitVersionTask/NugetAssets/GitVersionTask.nuspec @@ -1,19 +1,38 @@ - - - + + + GitVersionTask - $version$ + 1.0.0 GitVersionTask GitTools and Contributors GitTools and Contributors + false + true http://www.opensource.org/licenses/mit-license.php https://github.com/GitTools/GitVersion https://raw.githubusercontent.com/GitTools/GitVersion/master/docs/img/package_icon.png - false Stamps an assembly with git information based on SemVer. - en-AU - Git Versioning GitVersion GitFlowVersion GitFlow GitHubFlow SemVer - true https://github.com/GitTools/GitVersion/releases + Copyright GitTools 2015. + Git Versioning GitVersion GitFlowVersion GitFlow GitHubFlow SemVer + + + + + + + + + + + + + - + + + + + + + \ No newline at end of file diff --git a/src/GitVersionTask/NugetAssets/build/GitVersionTask.targets b/src/GitVersionTask/NugetAssets/build/GitVersionTask.targets index 7247e6a4c2..1d50060976 100644 --- a/src/GitVersionTask/NugetAssets/build/GitVersionTask.targets +++ b/src/GitVersionTask/NugetAssets/build/GitVersionTask.targets @@ -1,156 +1,18 @@ - - - - True - - - $(MSBuildProjectDirectory)\..\ - $(SolutionDir) - $(MSBuildProjectDirectory) - $(SolutionDir)\GitVersionTask.targets - $(SolutionDir)\GitVersionTask.targets - - $(MSBuildProjectDirectory)\obj\$(Configuration)\ - false - - - false - true - - - false - false - true - - - false - true + - - true - false - - - false - true - - $(GetPackageVersionDependsOn);GetVersion + + + + - $(MSBuildThisFileDirectory) + + false + true - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - $(GitVersion_FullSemVer) - $(GitVersion_MajorMinorPatch) - $(GitVersion_NuGetPreReleaseTag) - $(GitVersion_PreReleaseTag) - $(GitVersion_NuGetVersion) - $(GitVersion_FullSemVer) - $(GitVersion_InformationalVersion) - $(GitVersion_AssemblySemVer) - $(GitVersion_AssemblySemFileVer) - - - - - - - - False - - - False - - - False - - + + + + - + \ No newline at end of file diff --git a/src/GitVersionTask/NugetAssets/build/Infrastructure.props b/src/GitVersionTask/NugetAssets/build/Infrastructure.props new file mode 100644 index 0000000000..edeacf76e0 --- /dev/null +++ b/src/GitVersionTask/NugetAssets/build/Infrastructure.props @@ -0,0 +1,42 @@ + + + + + + $(MSBuildThisFileDirectory)functionality/ + $(GitVersionTaskBuildTools_FunctionalityDir)GitVersionBuild.targets + $(GitVersionTaskBuildTools_FunctionalityDir)GitVersionMultiTargetBuild.targets + $(GitVersionTaskBuildTools_FunctionalityDir)obj/ + + + + $(PackageVersion_UtilPackNuGetMSBuild) + $(MSBuildThisFileDirectory)../../../utilpack.nuget.msbuild/$(UtilPackVersion)/build/UtilPack.NuGet.MSBuild.props + $([System.IO.Path]::GetFullPath('$(UtilPackNuGetMSBuildPropsPath)')) + + + + + + true + + + + + .NETFramework + 4.6.1 + + + $(UtilPackTaskFactoryParametersXML) + true + GitVersionTask.dll + + + + + + + + + + \ No newline at end of file diff --git a/src/GitVersionTask/NugetAssets/build/functionality/GitVersionBuild.targets b/src/GitVersionTask/NugetAssets/build/functionality/GitVersionBuild.targets new file mode 100644 index 0000000000..95d8e40022 --- /dev/null +++ b/src/GitVersionTask/NugetAssets/build/functionality/GitVersionBuild.targets @@ -0,0 +1,104 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + $(GitVersion_FullSemVer) + $(GitVersion_MajorMinorPatch) + $(GitVersion_NuGetPreReleaseTag) + $(GitVersion_PreReleaseTag) + $(GitVersion_NuGetVersion) + $(GitVersion_FullSemVer) + $(GitVersion_InformationalVersion) + $(GitVersion_AssemblySemVer) + $(GitVersion_AssemblySemFileVer) + + + + + + + + False + + + False + + + False + + + + diff --git a/src/GitVersionTask/NugetAssets/build/functionality/GitVersionCommon.props b/src/GitVersionTask/NugetAssets/build/functionality/GitVersionCommon.props new file mode 100644 index 0000000000..9b303d0bc8 --- /dev/null +++ b/src/GitVersionTask/NugetAssets/build/functionality/GitVersionCommon.props @@ -0,0 +1,76 @@ + + + + $(MSBuildProjectDirectory)\..\ + $(SolutionDir) + $(MSBuildProjectDirectory) + $(SolutionDir)\GitVersionTask.targets + $(SolutionDir)\GitVersionTask.targets + + false + $(MSBuildProjectDirectory)\obj\$(Configuration)\ + + + false + true + + + false + false + true + + + false + true + + false + true + + $(GetPackageVersionDependsOn);GetVersion + + + true + false + + + + + $(UtilPackTaskFactoryParametersXML) + + + + + $(UtilPackTaskFactoryParametersXML) + + + + + $(UtilPackTaskFactoryParametersXML) + + + + + $(UtilPackTaskFactoryParametersXML) + + + + True + + + \ No newline at end of file diff --git a/src/GitVersionTask/NugetAssets/buildMultiTargeting/GitVersionTask.targets b/src/GitVersionTask/NugetAssets/build/functionality/GitVersionMultiTargetBuild.targets similarity index 52% rename from src/GitVersionTask/NugetAssets/buildMultiTargeting/GitVersionTask.targets rename to src/GitVersionTask/NugetAssets/build/functionality/GitVersionMultiTargetBuild.targets index ffd55b4cc2..379ff192cb 100644 --- a/src/GitVersionTask/NugetAssets/buildMultiTargeting/GitVersionTask.targets +++ b/src/GitVersionTask/NugetAssets/build/functionality/GitVersionMultiTargetBuild.targets @@ -1,63 +1,12 @@  - - True - - - $(MSBuildProjectDirectory)\..\ - $(SolutionDir) - $(MSBuildProjectDirectory) - $(SolutionDir)\GitVersionTask.targets - $(SolutionDir)\GitVersionTask.targets - - false - - - false - true - - - false - false - true - - - false - true - - false - true - - $(GetPackageVersionDependsOn);GetVersion - - - true - false - - $(MSBuildThisFileDirectory)..\build\ - - - - - - - - + - diff --git a/src/GitVersionTask/UpdateAssemblyInfo.cs b/src/GitVersionTask/UpdateAssemblyInfo.cs index f6972f9139..b299fcbc93 100644 --- a/src/GitVersionTask/UpdateAssemblyInfo.cs +++ b/src/GitVersionTask/UpdateAssemblyInfo.cs @@ -1,11 +1,13 @@ namespace GitVersionTask { using System; - using System.ComponentModel; using System.IO; + using System.Text; + using GitVersion; using GitVersion.Helpers; using Microsoft.Build.Framework; + using GitTools; public class UpdateAssemblyInfo : GitVersionTaskBase { diff --git a/src/GitVersionTask/UtilPack.Version.props b/src/GitVersionTask/UtilPack.Version.props new file mode 100644 index 0000000000..978b7de7dc --- /dev/null +++ b/src/GitVersionTask/UtilPack.Version.props @@ -0,0 +1,6 @@ + + + 2.4.0 + + + diff --git a/src/GitVersionTask/WriteVersionInfoToBuildLog.cs b/src/GitVersionTask/WriteVersionInfoToBuildLog.cs index 32715053a5..aa4b4c6e1e 100644 --- a/src/GitVersionTask/WriteVersionInfoToBuildLog.cs +++ b/src/GitVersionTask/WriteVersionInfoToBuildLog.cs @@ -2,11 +2,9 @@ { using System; using System.Collections.Generic; - using System.ComponentModel; - using GitVersion; - using Microsoft.Build.Framework; + using GitTools; public class WriteVersionInfoToBuildLog : GitVersionTaskBase { diff --git a/src/GitVersionTask/app.config b/src/GitVersionTask/app.config index b57ccf84c3..a01b86a142 100644 --- a/src/GitVersionTask/app.config +++ b/src/GitVersionTask/app.config @@ -1,11 +1,6 @@  - - - - - - + \ No newline at end of file diff --git a/src/GitVersionTask/key.snk b/src/GitVersionTask/key.snk new file mode 100644 index 0000000000..17a1bfef71 Binary files /dev/null and b/src/GitVersionTask/key.snk differ diff --git a/src/GitVersionTask/packages.config b/src/GitVersionTask/packages.config deleted file mode 100644 index d94e9e5e27..0000000000 --- a/src/GitVersionTask/packages.config +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/src/NuGet.config b/src/NuGet.config new file mode 100644 index 0000000000..20d8e217a4 --- /dev/null +++ b/src/NuGet.config @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/src/global.json b/src/global.json new file mode 100644 index 0000000000..4d61027af6 --- /dev/null +++ b/src/global.json @@ -0,0 +1,5 @@ +{ + "sdk": { + "version": "2.0.0" + } +} \ No newline at end of file diff --git a/tools/packages.config b/tools/packages.config index 4bc41f6930..0f070f2afe 100644 --- a/tools/packages.config +++ b/tools/packages.config @@ -1,5 +1,5 @@ - - + +