mirror of
https://github.com/zoriya/octokit.net.git
synced 2025-12-06 07:16:09 +00:00
Fix assembly versioning/properties and handle platform exception (#1660)
* Use assembly version instead of hard-coded ones Builds happening on AppVeyor specify the assembly version with `dotnet build /p:Version=<gitversion>` * Set default version for dev time This is to avoid that the default 1.0.0 version be assigned to the assemblies * Move various package/assembly properties from AssemblyInfo into csproj files so dotnet build can set them all * Get rid of SolutionInfo and move assembly version function into Connection class * Rework FormatUserAgent to use InformationalVersion and guard against exceptions determining platform OS/arch (fixes #1617) * Update assembly descriptions * Reword dotnetcore to .NET Core * Attempted workaround for package version dependency issue by specifying version on dotnet restore see https://github.com/NuGet/Home/issues/4337
This commit is contained in:
@@ -1,22 +1,23 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<Description>An IObservable based GitHub API client library for .NET using Reactive Extensions</Description>
|
||||
<Description>An IObservable based GitHub API client library for .NET and .NET Core using Reactive Extensions</Description>
|
||||
<AssemblyTitle>Octokit.Reactive</AssemblyTitle>
|
||||
<Authors>GitHub</Authors>
|
||||
<Version>0.0.0-dev</Version>
|
||||
<TargetFrameworks>netstandard1.1;net45</TargetFrameworks>
|
||||
<AssemblyName>Octokit.Reactive</AssemblyName>
|
||||
<PackageId>Octokit.Reactive</PackageId>
|
||||
<GenerateAssemblyTitleAttribute>false</GenerateAssemblyTitleAttribute>
|
||||
<GenerateAssemblyDescriptionAttribute>false</GenerateAssemblyDescriptionAttribute>
|
||||
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
|
||||
<GenerateAssemblyVersionAttribute>false</GenerateAssemblyVersionAttribute>
|
||||
<GenerateAssemblyFileVersionAttribute>false</GenerateAssemblyFileVersionAttribute>
|
||||
<DebugType>embedded</DebugType>
|
||||
<RepositoryUrl>https://github.com/octokit/octokit.net</RepositoryUrl>
|
||||
<PackageProjectUrl>https://github.com/octokit/octokit.net</PackageProjectUrl>
|
||||
<PackageIconUrl>https://f.cloud.github.com/assets/19977/1510987/64af2b26-4a9d-11e3-89fc-96a185171c75.png</PackageIconUrl>
|
||||
<PackageTags>GitHub API Octokit linqpad-samples dotnetcore</PackageTags>
|
||||
<Copyright>Copyright GitHub 2017</Copyright>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Include="..\SolutionInfo.cs;..\Octokit\Helpers\Ensure.cs;..\Octokit\Helpers\Pagination.cs" />
|
||||
<Compile Include="..\Octokit\Helpers\Ensure.cs;..\Octokit\Helpers\Pagination.cs" />
|
||||
<None Include="app.config" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
using System.Reflection;
|
||||
|
||||
[assembly: AssemblyTitle("Octokit.Reactive")]
|
||||
[assembly: AssemblyDescription("An IObservable based GitHub API client library for .NET using Reactive Extensions")]
|
||||
@@ -4,6 +4,7 @@ using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Reflection;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Octokit.Internal;
|
||||
@@ -696,26 +697,60 @@ namespace Octokit
|
||||
|
||||
static string FormatUserAgent(ProductHeaderValue productInformation)
|
||||
{
|
||||
var format =
|
||||
#if !HAS_ENVIRONMENT
|
||||
"{0} ({1}; {2}; {3}; Octokit {4})";
|
||||
#else
|
||||
"{0} ({1} {2}; {3}; {4}; Octokit {5})";
|
||||
#endif
|
||||
|
||||
return string.Format(CultureInfo.InvariantCulture,
|
||||
format,
|
||||
return string.Format(CultureInfo.InvariantCulture, "{0} ({1}; {2}; Octokit {3})",
|
||||
productInformation,
|
||||
GetPlatformInformation(),
|
||||
GetCultureInformation(),
|
||||
GetVersionInformation());
|
||||
}
|
||||
|
||||
private static string _platformInformation;
|
||||
static string GetPlatformInformation()
|
||||
{
|
||||
if (string.IsNullOrEmpty(_platformInformation))
|
||||
{
|
||||
try
|
||||
{
|
||||
_platformInformation = string.Format(CultureInfo.InvariantCulture,
|
||||
#if !HAS_ENVIRONMENT
|
||||
RuntimeInformation.OSDescription,
|
||||
RuntimeInformation.OSArchitecture.ToString().ToLowerInvariant(),
|
||||
"{0}; {1}",
|
||||
RuntimeInformation.OSDescription.Trim(),
|
||||
RuntimeInformation.OSArchitecture.ToString().ToLowerInvariant().Trim()
|
||||
#else
|
||||
Environment.OSVersion.Platform,
|
||||
Environment.OSVersion.Version.ToString(3),
|
||||
Environment.Is64BitOperatingSystem ? "amd64" : "x86",
|
||||
"{0} {1}; {2}",
|
||||
Environment.OSVersion.Platform,
|
||||
Environment.OSVersion.Version.ToString(3),
|
||||
Environment.Is64BitOperatingSystem ? "amd64" : "x86"
|
||||
#endif
|
||||
CultureInfo.CurrentCulture.Name,
|
||||
AssemblyVersionInformation.Version);
|
||||
);
|
||||
}
|
||||
catch
|
||||
{
|
||||
_platformInformation = "Unknown Platform";
|
||||
}
|
||||
}
|
||||
|
||||
return _platformInformation;
|
||||
}
|
||||
|
||||
static string GetCultureInformation()
|
||||
{
|
||||
return CultureInfo.CurrentCulture.Name;
|
||||
}
|
||||
|
||||
private static string _versionInformation;
|
||||
static string GetVersionInformation()
|
||||
{
|
||||
if (string.IsNullOrEmpty(_versionInformation))
|
||||
{
|
||||
_versionInformation = typeof(IGitHubClient)
|
||||
.GetTypeInfo()
|
||||
.Assembly
|
||||
.GetCustomAttribute<AssemblyInformationalVersionAttribute>()
|
||||
.InformationalVersion;
|
||||
}
|
||||
|
||||
return _versionInformation;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,24 +1,21 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<Description>An async-based GitHub API client library for .NET</Description>
|
||||
<Description>An async-based GitHub API client library for .NET and .NET Core</Description>
|
||||
<AssemblyTitle>Octokit</AssemblyTitle>
|
||||
<Authors>GitHub</Authors>
|
||||
<Version>0.0.0-dev</Version>
|
||||
<TargetFrameworks>netstandard1.1;net45</TargetFrameworks>
|
||||
<AssemblyName>Octokit</AssemblyName>
|
||||
<PackageId>Octokit</PackageId>
|
||||
<GenerateAssemblyTitleAttribute>false</GenerateAssemblyTitleAttribute>
|
||||
<GenerateAssemblyDescriptionAttribute>false</GenerateAssemblyDescriptionAttribute>
|
||||
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
|
||||
<GenerateAssemblyVersionAttribute>false</GenerateAssemblyVersionAttribute>
|
||||
<GenerateAssemblyFileVersionAttribute>false</GenerateAssemblyFileVersionAttribute>
|
||||
<DebugType>embedded</DebugType>
|
||||
<RepositoryUrl>https://github.com/octokit/octokit.net</RepositoryUrl>
|
||||
<PackageProjectUrl>https://github.com/octokit/octokit.net</PackageProjectUrl>
|
||||
<PackageIconUrl>https://f.cloud.github.com/assets/19977/1510987/64af2b26-4a9d-11e3-89fc-96a185171c75.png</PackageIconUrl>
|
||||
<PackageTags>GitHub API Octokit linqpad-samples dotnetcore</PackageTags>
|
||||
<Copyright>Copyright GitHub 2017</Copyright>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Include="..\SolutionInfo.cs" />
|
||||
</ItemGroup>
|
||||
|
||||
<PropertyGroup Condition=" '$(TargetFramework)' == 'netstandard1.1' ">
|
||||
<DefineConstants>$(DefineConstants);HAS_TYPEINFO;SIMPLE_JSON_INTERNAL;SIMPLE_JSON_OBJARRAYINTERNAL;SIMPLE_JSON_READONLY_COLLECTIONS;SIMPLE_JSON_TYPEINFO;NO_SERIALIZABLE</DefineConstants>
|
||||
</PropertyGroup>
|
||||
|
||||
@@ -1,6 +1,3 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
[assembly: AssemblyTitle("Octokit")]
|
||||
[assembly: AssemblyDescription("An async-based GitHub API client library for .NET")]
|
||||
[assembly: InternalsVisibleTo("Octokit.Tests")]
|
||||
@@ -1,16 +0,0 @@
|
||||
// <auto-generated/>
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
[assembly: AssemblyProductAttribute("Octokit")]
|
||||
[assembly: AssemblyVersionAttribute("0.24.0")]
|
||||
[assembly: AssemblyFileVersionAttribute("0.24.0")]
|
||||
[assembly: ComVisibleAttribute(false)]
|
||||
namespace System
|
||||
{
|
||||
internal static class AssemblyVersionInformation
|
||||
{
|
||||
internal const string Version = "0.24.0";
|
||||
internal const string InformationalVersion = "0.24.0";
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
using Cake.Common.Tools.DotNetCore;
|
||||
using Cake.Common.Tools.DotNetCore.Restore;
|
||||
using Cake.Core;
|
||||
using Cake.Frosting;
|
||||
|
||||
[Dependency(typeof(Clean))]
|
||||
@@ -7,6 +8,10 @@ public sealed class Restore : FrostingTask<Context>
|
||||
{
|
||||
public override void Run(Context context)
|
||||
{
|
||||
context.DotNetCoreRestore(".");
|
||||
context.DotNetCoreRestore(".", new DotNetCoreRestoreSettings
|
||||
{
|
||||
ArgumentCustomization = args => args
|
||||
.Append("/p:Version={0}", context.Version.GetSemanticVersion())
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user