Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add netcoreapp3.0 global tool #315

Closed
wants to merge 24 commits into from
Closed
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,13 @@ jobs:
displayName: Set build number

- task: DotNetCoreInstaller@0
displayName: Install .NET Core SDK 2.1.500
displayName: Install .NET Core SDK
inputs:
packageType: sdk
version: 2.1.500
version: 3.0.100-preview4-011223
- script: dotnet --info
displayName: Show dotnet SDK info
workingDirectory: src

- task: DotNetCoreCLI@2
displayName: Restore NuGet packages
Expand Down
4 changes: 3 additions & 1 deletion build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ Param(
[string]$MsBuildVerbosity = 'minimal'
)

$msbuildCommandLine = "msbuild `"$PSScriptRoot\src\Nerdbank.GitVersioning.sln`" /m /verbosity:$MsBuildVerbosity /nologo /p:Platform=`"Any CPU`" /t:build,pack"
$msbuildCommandLine = "dotnet build `"$PSScriptRoot\src\Nerdbank.GitVersioning.sln`" /m /verbosity:$MsBuildVerbosity /nologo /p:Platform=`"Any CPU`" /t:build,pack"
$msbuildPublish = "dotnet publish .\src\nbgv\nbgv.csproj -f netcoreapp2.1 -o .\src\nerdbank-gitversioning.npm\out\nbgv.cli\tools\netcoreapp2.1\any"

if (Test-Path "C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll") {
$msbuildCommandLine += " /logger:`"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll`""
Expand All @@ -34,6 +35,7 @@ try {
}
}

Invoke-Expression $msbuildPublish
if ($PSCmdlet.ShouldProcess("$PSScriptRoot\src\nerdbank-gitversioning.npm", "gulp")) {
cd "$PSScriptRoot\src\nerdbank-gitversioning.npm"
yarn run build
Expand Down
2 changes: 0 additions & 2 deletions src/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
<Project>
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<BaseIntermediateOutputPath>$(MSBuildThisFileDirectory)..\obj\$(MSBuildProjectName)\</BaseIntermediateOutputPath>
<OutputPath>$(MSBuildThisFileDirectory)..\bin\$(MSBuildProjectName)\$(Configuration)\</OutputPath>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This combined with TargetFrameworks does not work. It is easier to just dotnet publish.

<DocumentationRootFolder>$(MSBuildThisFileDirectory)..\wiki\api</DocumentationRootFolder>
<LangVersion>7.3</LangVersion>

Expand Down
4 changes: 2 additions & 2 deletions src/global.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"sdk": {
"version": "2.1.500"
"version": "3.0.100-preview4-011223"
}
}
}
35 changes: 2 additions & 33 deletions src/nbgv/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,6 @@ namespace Nerdbank.GitVersioning.Tool
using System.Threading;
using System.Threading.Tasks;
using Newtonsoft.Json;
using NuGet.Common;
using NuGet.Configuration;
using NuGet.PackageManagement;
using NuGet.Protocol;
using NuGet.Protocol.Core.Types;
using NuGet.Resolver;
using Validation;
using MSBuild = Microsoft.Build.Evaluation;

Expand Down Expand Up @@ -639,34 +633,9 @@ private static ExitCodes OnPrepareReleaseCommand(string projectPath, string prer
}
}

private static async Task<string> GetLatestPackageVersionAsync(string packageId, CancellationToken cancellationToken = default)
private static Task<string> GetLatestPackageVersionAsync(string packageId, CancellationToken cancellationToken = default)
{
var providers = new List<Lazy<INuGetResourceProvider>>();
providers.AddRange(Repository.Provider.GetCoreV3()); // Add v3 API support

// We SHOULD use all the sources from the target's nuget.config file.
// But I don't know what API to use to do that.
var packageSource = new PackageSource("https://api.nuget.org/v3/index.json");

var sourceRepository = new SourceRepository(packageSource, providers);
var resolutionContext = new ResolutionContext(
DependencyBehavior.Highest,
includePrelease: false,
includeUnlisted: false,
VersionConstraints.None);

// The target framework doesn't matter, since our package doesn't depend on this for its target projects.
var framework = new NuGet.Frameworks.NuGetFramework("net45");

var pkg = await NuGetPackageManager.GetLatestVersionAsync(
packageId,
framework,
resolutionContext,
sourceRepository,
NullLogger.Instance,
cancellationToken);

return pkg.LatestVersion.ToNormalizedString();
return Task.FromResult("2.3.138"); // TODO
}

private static string GetSpecifiedOrCurrentDirectoryPath(string versionJsonRoot)
Expand Down
4 changes: 1 addition & 3 deletions src/nbgv/nbgv.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,12 @@
<ToolCommandName>nbgv</ToolCommandName>
<PackAsTool>True</PackAsTool>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.1</TargetFramework>
<TargetFrameworks>netcoreapp2.1;netcoreapp3.0</TargetFrameworks>
<RootNamespace>Nerdbank.GitVersioning.Tool</RootNamespace>
<Description>A .NET Core Tool that can install, read and set version information based on git history, using Nerdbank.GitVersioning.</Description>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="NuGet.PackageManagement" Version="4.9.3" NoWarn="NU1701" />
<PackageReference Include="NuGet.Resolver" Version="4.9.3" />
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These were only used by GetLatestPackageVersionAsync. They are netframework only and cause a bunch of dependency problems. Hopefully there is an easier way with NuGet 5.0.

<PackageReference Include="System.CommandLine" Version="0.1.0-preview2-180503-2" />
<PackageReference Include="Nerdbank.GitVersioning.LKG" Version="1.6.20-beta-gfea83a8c9e" PrivateAssets="all" />
<PackageReference Include="System.Diagnostics.Tools" Version="4.3.0" />
Expand Down