ctaggart / froto

Froto: F# Protocol Buffers
MIT License
146 stars 27 forks source link

use Nerdbank.GitVersioning #100

Closed ctaggart closed 5 years ago

ctaggart commented 5 years ago

This revising the build system to use versioning from https://github.com/AArnott/Nerdbank.GitVersioning. It is one step closer to being fully deterministic so that you can build the same package locally, on AppVeyor, on Travis CI, on Azure Pipelines, or any other CI and get the same bytes. For convenience, the prelease versions are simply the git commit short and match git rev-parse --short HEAD as well as what GitHub shows.

@7sharp9, you should be able to run./build.ps1 and get a nupkg to try out elsewhere.


I'm getting libgit2sharp warning when I add this:

dotnet build Parser/Froto.Parser.fsproj
  Froto.Parser -> /Users/cameron/github/froto/Parser/bin/Debug/netstandard2.0/Froto.Parser.dll

Build succeeded.

/Users/cameron/.nuget/packages/microsoft.build.tasks.git/1.0.0-beta2-18618-05/build/Microsoft.Build.Tasks.Git.targets(20,5): warning : StrictFilePathMarshaler must be used on a FilePath. [/Users/cameron/github/froto/Parser/Froto.Parser.fsproj]
/Users/cameron/.nuget/packages/microsoft.build.tasks.git/1.0.0-beta2-18618-05/build/Microsoft.Build.Tasks.Git.targets(20,5): warning :    at LibGit2Sharp.Core.StrictFilePathMarshaler.MarshalManagedToNative(Object managedObj) [/Users/cameron/github/froto/Parser/Froto.Parser.fsproj]
/Users/cameron/.nuget/packages/microsoft.build.tasks.git/1.0.0-beta2-18618-05/build/Microsoft.Build.Tasks.Git.targets(20,5): warning :    at System.StubHelpers.MngdRefCustomMarshaler.ConvertContentsToNative(IntPtr pMarshalState, Object& pManagedHome, IntPtr pNativeHome) [/Users/cameron/github/froto/Parser/Froto.Parser.fsproj]
/Users/cameron/.nuget/packages/microsoft.build.tasks.git/1.0.0-beta2-18618-05/build/Microsoft.Build.Tasks.Git.targets(20,5): warning :    at LibGit2Sharp.Core.NativeMethods.git_repository_discover(GitBuf buf, FilePath start_path, Boolean across_fs, FilePath ceiling_dirs) [/Users/cameron/github/froto/Parser/Froto.Parser.fsproj]
/Users/cameron/.nuget/packages/microsoft.build.tasks.git/1.0.0-beta2-18618-05/build/Microsoft.Build.Tasks.Git.targets(20,5): warning :    at LibGit2Sharp.Core.Proxy.ConvertPath(Func`2 pathRetriever) [/Users/cameron/github/froto/Parser/Froto.Parser.fsproj]
/Users/cameron/.nuget/packages/microsoft.build.tasks.git/1.0.0-beta2-18618-05/build/Microsoft.Build.Tasks.Git.targets(20,5): warning :    at LibGit2Sharp.Repository.Discover(String startingPath) [/Users/cameron/github/froto/Parser/Froto.Parser.fsproj]
/Users/cameron/.nuget/packages/microsoft.build.tasks.git/1.0.0-beta2-18618-05/build/Microsoft.Build.Tasks.Git.targets(20,5): warning :    at Microsoft.Build.Tasks.Git.GitOperations.LocateRepository(String directory) in /_/src/Microsoft.Build.Tasks.Git.Operations/GitOperations.cs:line 26 [/Users/cameron/github/froto/Parser/Froto.Parser.fsproj]
/Users/cameron/.nuget/packages/microsoft.build.tasks.git/1.0.0-beta2-18618-05/build/Microsoft.Build.Tasks.Git.targets(20,5): warning :    at Microsoft.Build.Tasks.Git.RepositoryTasks.LocateRepository(LocateRepository task) in /_/src/Microsoft.Build.Tasks.Git.Operations/RepositoryTasks.cs:line 58 [/Users/cameron/github/froto/Parser/Froto.Parser.fsproj]
/Users/cameron/.nuget/packages/microsoft.sourcelink.common/1.0.0-beta2-18618-05/build/Microsoft.SourceLink.Common.targets(53,5): warning : Source control information is not available - the generated source link is empty. [/Users/cameron/github/froto/Parser/Froto.Parser.fsproj]
/Users/cameron/github/froto/Parser/obj/Debug/netstandard2.0/Froto.Parser.Version.fs(14,69): warning FS2003: The attribute System.Reflection.AssemblyInformationalVersionAttribute specified version '0.0.125+40a86c726a', but this value is invalid and has been ignored [/Users/cameron/github/froto/Parser/Froto.Parser.fsproj]
    3 Warning(s)
    0 Error(s)

Time Elapsed 00:00:04.77
ctaggart commented 5 years ago

Travis CI build failed with:

7.44s$ dotnet test Parser.Test/Froto.Parser.Test.fsproj
/home/travis/.nuget/packages/nerdbank.gitversioning/2.3.136/build/Nerdbank.GitVersioning.targets(63,5): error MSB4018: The "Nerdbank.GitVersioning.Tasks.GetBuildVersion" task failed unexpectedly. [/home/travis/build/ctaggart/froto/Parser/Froto.Parser.fsproj]
/home/travis/.nuget/packages/nerdbank.gitversioning/2.3.136/build/Nerdbank.GitVersioning.targets(63,5): error MSB4018: System.TypeInitializationException: The type initializer for 'LibGit2Sharp.Core.NativeMethods' threw an exception. ---> System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.DotNet.PlatformAbstractions, Version=2.1.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified. [/home/travis/build/ctaggart/froto/Parser/Froto.Parser.fsproj]
/home/travis/.nuget/packages/nerdbank.gitversioning/2.3.136/build/Nerdbank.GitVersioning.targets(63,5): error MSB4018:  [/home/travis/build/ctaggart/froto/Parser/Froto.Parser.fsproj]
/home/travis/.nuget/packages/nerdbank.gitversioning/2.3.136/build/Nerdbank.GitVersioning.targets(63,5): error MSB4018:    at Nerdbank.GitVersioning.GitLoaderContext.GetNativeLibraryDirectory() [/home/travis/build/ctaggart/froto/Parser/Froto.Parser.fsproj]
/home/travis/.nuget/packages/nerdbank.gitversioning/2.3.136/build/Nerdbank.GitVersioning.targets(63,5): error MSB4018:    at Nerdbank.GitVersioning.GitLoaderContext.LoadUnmanagedDll(String unmanagedDllName) [/home/travis/build/ctaggart/froto/Parser/Froto.Parser.fsproj]
ctaggart commented 5 years ago

By default without a version.json, it produced: /Users/cameron/github/froto/Parser/obj/Debug/netstandard2.0/Froto.Parser.Version.fs

//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//     Runtime Version:4.0.30319.42000
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

namespace Froto.Parser
[<assembly: System.Reflection.AssemblyVersionAttribute("0.0.0.0")>]
[<assembly: System.Reflection.AssemblyFileVersionAttribute("0.0.125.43072")>]
[<assembly: System.Reflection.AssemblyInformationalVersionAttribute("0.0.125+40a86c726a")>]
do()
[<System.CodeDom.Compiler.GeneratedCode("Nerdbank.GitVersioning.Tasks","2.3.136.25003")>]
type internal ThisAssembly() =
  static member internal AssemblyVersion = "0.0.0.0"
  static member internal AssemblyFileVersion = "0.0.125.43072"
  static member internal AssemblyInformationalVersion = "0.0.125+40a86c726a"
  static member internal AssemblyName = "Froto.Parser"
  static member internal AssemblyTitle = "Froto.Parser"
  static member internal AssemblyConfiguration = "Debug"
  static member internal GitCommitId = "40a86c726a95abca52dd1fece35727c497f6b86a"
  static member internal RootNamespace = "Froto.Parser"
do()

It did not conflict with: /Users/cameron/github/froto/Parser/obj/Debug/netstandard2.0/Froto.Parser.AssemblyInfo.fs

// <auto-generated>
//     Generated by the FSharp WriteCodeFragment class.
// </auto-generated>
namespace FSharp

open System
open System.Reflection

[<assembly: System.Reflection.AssemblyCompanyAttribute("Cameron Taggart, James Hugard")>]
[<assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")>]
[<assembly: System.Reflection.AssemblyDescriptionAttribute("A parser for .proto files for Protocol Buffers.")>]
[<assembly: System.Reflection.AssemblyProductAttribute("Froto.Parser")>]
[<assembly: System.Reflection.AssemblyTitleAttribute("Froto.Parser")>]
do()