Replies: 8 comments 34 replies
-
Unfortunately we do not have people to maintain the codebase for the .net framework, so we decided to focus on LTS .NET only |
Beta Was this translation helpful? Give feedback.
-
|
I'm using GitVersion.MSBuild and I did hit a different problem with 6.0.2 not being able to build with Visual Studio. It may shed light. The build error was: It did compile fine with dotnet cli. I found a work around of removing the following line from my csproj: Rob |
Beta Was this translation helpful? Give feedback.
-
|
Hi @Szaamaan I've had a go at reproducing your issue and it seems that GitVersion is not running as So ... I enabled I do not know why
|
Beta Was this translation helpful? Give feedback.
-
|
Ah, I see: #4116 |
Beta Was this translation helpful? Give feedback.
-
|
Digging a little more I notice that 5.12.0 show .NET Standard 2.0 dependency while 6.0.0 does not. I believe that .NET 2.0 works with both dotnet cli and VS. |
Beta Was this translation helpful? Give feedback.
-
|
I'm doing a pass of nuget upgrades in my project and noticed GitVersion.MsBuild stopped working too (my files became 1.0.0). What's the use of this nuget if it doesn't support Visual Studio? On my release build pipeline it's going through dotnet-gitversion and dotnet publish and it work, so this nuget is not required. But on a developer machine machine running the solution via Visual Studio, I was expecting the nuget task to run to stamp the version. Even had a "Condition="'$(Configuration)'=='Debug'" on the PackageReference. Is there any different workflow I could use, or should I simply remain on 5.12.0? |
Beta Was this translation helpful? Give feedback.
-
|
I've ran into a scenario that requires us to upgrade to 6.X from 5.12.0 (#3699) but quite quickly discovered that 6.X isn't supported by Visual Studio. For some additional background context: We build pre-release nuget packages on our own machines using Visual Studio and depend on these packages elsewhere via local NuGet feeds. These pre-release packages can then be used for testing in the project that depends on it. Once the feature is complete, only then are the changes merged and pushed to origin triggering a My understanding is that .NET Framework MSBuild support was dropped, leading to Visual Studio no longer being supported. What needs to happen for this to become viable again? |
Beta Was this translation helpful? Give feedback.
-
|
I’m not sure if this helps, but I’ve come up with the following workaround:
This approach is demonstrated in my test Console application, but the concept should apply to any project type. <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="GitVersion.MsBuild" Version="6.4.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
<!--#region Enables GitVersion to work with Visual Studio-->
<Target Name="GetVersionForVisualStudio" AfterTargets="GetVersion">
<Exec Command="dotnet gitversion -output file -outputfile $(ProjectDir)\$(GitVersionOutputFile)" />
<ReadLinesFromFile File="$(ProjectDir)\$(GitVersionOutputFile)">
<Output TaskParameter="Lines" PropertyName="GitVersionInformation" />
</ReadLinesFromFile>
<ItemGroup>
<AssemblyAttribute Include="System.Reflection.AssemblyMetadataAttribute">
<_Parameter1>GitVersionInformation</_Parameter1>
<_Parameter2>$(GitVersionInformation)</_Parameter2>
</AssemblyAttribute>
</ItemGroup>
</Target>
<!--#endregion-->
</Project>and here's the sample console application reading the GitVersionInformation: // Program.cs
using System.Reflection;
using System.Text.Json;
using System.Text.Json.Nodes;
Console.WriteLine($"Sha: {GitVersionInfo.Sha}");
Console.WriteLine($"InformationalVersion: {GitVersionInfo.InformationalVersion}");
Console.WriteLine($"MajorMinorPatch: {GitVersionInfo.MajorMinorPatch}");
public static class GitVersionInfo
{
public static int Major => GetJsonProperty<int>("Major");
public static int Minor => GetJsonProperty<int>("Minor");
public static int Patch => GetJsonProperty<int>("Patch");
public static string PreReleaseTag => GetJsonProperty<string>("PreReleaseTag");
public static string PreReleaseTagWithDash => GetJsonProperty<string>("PreReleaseTagWithDash");
public static string PreReleaseLabel => GetJsonProperty<string>("PreReleaseLabel");
public static string PreReleaseLabelWithDash => GetJsonProperty<string>("PreReleaseLabelWithDash");
public static int? PreReleaseNumber => GetJsonProperty<int?>("PreReleaseNumber");
public static int BuildMetaData => GetJsonProperty<int>("BuildMetaData");
public static string BuildMetaDataPadded => GetJsonProperty<string>("BuildMetaDataPadded");
public static string FullBuildMetaData => GetJsonProperty<string>("FullBuildMetaData");
public static string MajorMinorPatch => GetJsonProperty<string>("MajorMinorPatch");
public static string SemVer => GetJsonProperty<string>("SemVer");
public static string LegacySemVer => GetJsonProperty<string>("LegacySemVer");
public static string LegacySemVerPadded => GetJsonProperty<string>("LegacySemVerPadded");
public static string AssemblySemVer => GetJsonProperty<string>("AssemblySemVer");
public static string AssemblySemFileVer => GetJsonProperty<string>("AssemblySemFileVer");
public static string FullSemVer => GetJsonProperty<string>("FullSemVer");
public static string InformationalVersion => GetJsonProperty<string>("InformationalVersion");
public static string BranchName => GetJsonProperty<string>("BranchName");
public static string EscapedBranchName => GetJsonProperty<string>("EscapedBranchName");
public static string Sha => GetJsonProperty<string>("Sha");
public static string ShortSha => GetJsonProperty<string>("ShortSha");
public static string NuGetVersionV2 => GetJsonProperty<string>("NuGetVersionV2");
public static string NuGetVersion => GetJsonProperty<string>("NuGetVersion");
public static string NuGetPreReleaseTagV2 => GetJsonProperty<string>("NuGetPreReleaseTagV2");
public static string NuGetPreReleaseTag => GetJsonProperty<string>("NuGetPreReleaseTag");
public static string VersionSourceSha => GetJsonProperty<string>("VersionSourceSha");
public static int CommitsSinceVersionSource => GetJsonProperty<int>("CommitsSinceVersionSource");
public static string CommitsSinceVersionSourcePadded => GetJsonProperty<string>("CommitsSinceVersionSourcePadded");
public static int UncommittedChanges => GetJsonProperty<int>("UncommittedChanges");
public static string CommitDate => GetJsonProperty<string>("CommitDate");
public static JsonNode? Json { get; }
= (Assembly.GetExecutingAssembly() is Assembly assembly
&& assembly.GetCustomAttributes(typeof(AssemblyMetadataAttribute), false)
.Select(a => a as AssemblyMetadataAttribute)
.Where(ma => ma is not null && ma.Key.StartsWith("GitVersionInformation"))
.FirstOrDefault() is AssemblyMetadataAttribute attribute
&& attribute.Value is string text
&& !string.IsNullOrEmpty(text)
&& JsonNode.Parse(text.Replace(";", "")) is JsonNode json)
? json
: null;
public static T GetJsonProperty<T>(string key, T defaultValue = default(T))
=> Json is JsonObject obj
&& obj.TryGetPropertyValue(key, out var value)
&& value is not null
&& value.GetValue<T>() is T v
? v
: defaultValue;
}For a working demo: https://github.com/stephenquan/GitVersionTest |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Is this intended?
I've created a simple console application, just one line of code:
Console.WriteLine(GitVersionInformation.Sha);With an equally "simple" project file:
If I run
dotnet buildit'll compile. If I try to compile via Visual Studio it won't (GitVersionInformationwon't be available).This seems to be a deliberate change in v6 but... this can't be right, can it? You're effectively leaving every user of Visual Studio stranded at version 5...
Beta Was this translation helpful? Give feedback.
All reactions