question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

dotnet build --version-suffix not working?

See original GitHub issue

Steps to reproduce

project.json has the following version number :

{ "version": "1.1.0-beta-*" }

The following C# snippet I use for retrieve the version number :

public class Program { public static void Main(string[] args) { var versionInfo = (typeof(Program) .GetTypeInfo() .Assembly .GetCustomAttribute(typeof(AssemblyInformationalVersionAttribute)) as AssemblyInformationalVersionAttribute)?.InformationalVersion; Console.WriteLine(versionInfo); } }

After this I build with the following cli command :

dotnet build --version-suffix 1234

But the output of the programm would only “1.1.0-beta” without the suffix ? What did I miss?

Expected behavior

Output ‘1.1.0-beta-1234’

Actual behavior

Output ‘1.1.0-beta’

Environment data

`.NET Command Line Tools (1.0.0-preview2-003121)

Product Information: Version: 1.0.0-preview2-003121 Commit SHA-1 hash: 1e9d529bc5

Runtime Environment: OS Name: Windows OS Version: 6.1.7601 OS Platform: Windows RID: win7-x64`

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:20 (9 by maintainers)

github_iconTop GitHub Comments

44reactions
mloeffencommented, May 4, 2017

@NickCraver Try this in your csproj-file:

<VersionSuffix>$(VersionSuffix)</VersionSuffix>
<Version>1.0.6</Version>
<Version Condition=" '$(VersionSuffix)' != '' ">$(Version)-$(VersionSuffix)</Version>

This way people can set the Version-property through the Visual Studio UI and if you supply a VersionSuffix it still gets appended.

22reactions
NickCravercommented, Mar 18, 2017

@dasMulli After posting this, I dug in and realized the same: <Version>4.0.0</Version> with --version-suffix doesn’t work. That’s not intuitive, IMO. It’s a suffix, meaning it gets appended to the end…that’s the meaning of the word. Intuitively, I would expect the <Version> + <VersionSuffix> to work, or error when both are supplied since won’t work, due to it being unintuitive.

I think <VersionPrefix> is not the correct name, it’s really <VersionNumber> given the behavior.

I have moved to <VersionPrefix> in my projects, but it’s not a great. For example, if a user edits the Version through the UI (just once), that changes the .csproj from <VersionPrefix> to <Version> (both are there, but <Version> trumps), and all the build arguments just stop working. I just don’t agree with the current behavior, it defaults to failure and releasing not-ready code in several unintuitive and accidental cases.

As a practical impact: I will now have to make sure in every PR that no one used the UI to edit the version number in order to bump it (as one would intuitively do), since that will break all of my versioning until fixed.

Read more comments on GitHub >

github_iconTop Results From Across the Web

dotnet build --version-suffix not working? · Issue #6572
After this I build with the following cli command : dotnet build --version-suffix 1234. But the output of the programm would only ...
Read more >
How to use the dotnet-pack --version-suffix with csproj?
According the documentation, the Version property override the version on packing, instead, use the VersionPrefix .
Read more >
dotnet build command - .NET CLI
Sets the value of the $(VersionSuffix) property to use when building the project. This only works if the $(Version) property isn't set. Then,...
Read more >
Version vs VersionSuffix vs PackageVersion: What do they ...
In this post I look at the various version numbers you can set when building a .NET Core project, such as Version, VersionSuffix, ......
Read more >
Not possible to set VersionPrefix for dotnet Standard/Core ...
I didn't add VersionSuffix with Visual Studio GUI. I added only VersionPrefix by editing .csproj with a text editor... VersionSuffix's value come from...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found