dotnet / roslyn

The Roslyn .NET compiler provides C# and Visual Basic languages with rich code analysis APIs.
https://docs.microsoft.com/dotnet/csharp/roslyn-sdk/
MIT License
19.06k stars 4.04k forks source link

AssemblyInformationalVersionAttribute fails on SemVer2 strings #35793

Open rainersigwald opened 5 years ago

rainersigwald commented 5 years ago

Version Used: 3.100.19.22309 (ce8ac3f7)

Steps to Reproduce:

using System;
using System.Reflection;

[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.2.3-p.4.5+metadata")]

namespace Version
{
    class Program
    {
        static void Main(string[] args)
        { }
    }
}
PS C:\src\manualversion> csc Version.cs ; [System.Diagnostics.FileVersionInfo]::GetVersionInfo("C:\src\manualversion\version.exe") | fl                                                                                                                                   Microsoft (R) Visual C# Compiler version 3.100.19.22309 (ce8ac3f7)                                                                   Copyright (C) Microsoft Corporation. All rights reserved.

OriginalFilename  : ?
FileDescription   :
ProductName       :
Comments          :
CompanyName       :
FileName          : C:\src\manualversion\version.exe
FileVersion       : 0.0.0.0
ProductVersion    : 1.2.3-p.4.5+metadata
IsDebug           : False
IsPatched         : False
IsPreRelease      : False
IsPrivateBuild    : False
IsSpecialBuild    : False
Language          : Language Neutral
LegalCopyright    :
LegalTrademarks   :
PrivateBuild      :
SpecialBuild      :
FileVersionRaw    : 0.0.0.0
ProductVersionRaw : 0.0.0.0

Expected Behavior:

ProductVersionRaw : 1.2.3.0

This appears to be what you get if you have too many dots in the pre-release version section (after the dash). For instance, this works:

[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.2.3-p-4.5+metadata")]

but this does not:

[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.2.3-p-4.5.6+metadata")]

Actual Behavior:

ProductVersionRaw : 0.0.0.0

This manifests more importantly as a failure in

(Get-Command ./version.exe).Version

Which is how it was reported to MSBuild after the first Arcade + semver2 MSBuild builds rolled out into internal VS channels.

tmat commented 5 years ago

The issue might be in WriteVSFixedFileInfo

nguerrera commented 5 years ago

Is this a regression or is that always how informational version in this form was handled? Do we need to be concerned about a breaking change here?

tmat commented 5 years ago

This is how csc always worked. It didn't account for SemVer2. But there is no spec for parsing AIV, so we do best effort. We just looked at it with @jcouv and we think we can fix the compiler.

jcouv commented 5 years ago

@tmat What is the urgency of this issue at this point? I assume that your arcade mitigation went in already. Adding @jaredpar since I'm out this week and he wanted to discuss this (may be a feature rather than a bug, which may affect if/how we want to address this).

tmat commented 5 years ago

Not urgent. I don't see how this is more than a trivial to fix bug though.

DustinCampbell commented 5 years ago

FWIW, this is causing me a ton of pain because I can't build from VS command prompt. Is there a fix in sight?

nguerrera commented 5 years ago

@DustinCampbell It should be a matter of having an arcade with this change: https://github.com/dotnet/arcade/pull/2825

Is that not already the case?

tmat commented 5 years ago

@DustinCampbell Should be merged to Roslyn repo now. What repo are you working with?

DustinCampbell commented 5 years ago

https://github.com/dotnet/winforms-designer. Maybe we just took the update? Will try again this morning.

Update: This does work today.