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.

How to replicate auto version number

See original GitHub issue

Steps to reproduce

In previous version of .Net you could make part of your version number auto generated using an *.

E.g. 2.1.1.*

How can that be done in the new .Net Core csproj file?

I have read dotnet/sdk#7263, but that requires my CI to manage the dynamic part of the number.

Expected behaviour

In the project .csproj file using the following:-

<PropertyGroup>
  <VersionPrefix>2.1.3.*</VersionPrefix>
  <TargetFramework>netstandard1.4</TargetFramework>
</PropertyGroup>

Should produce a part dynamic version number on the produced assembly.

Actual behaviour

On running dotnet build

Build FAILED.

C:\Program Files\dotnet\sdk\1.0.4\Sdks\Microsoft.NET.Sdk\build\Microsoft.NET.GenerateAssemblyInfo.targets(120,5): error : Invalid NuGet version str
ing: '2.1.3.*'. [C:\_projects\misc\Html2Markdown\src\Html2Markdown\Html2Markdown.csproj]
C:\Program Files\dotnet\sdk\1.0.4\Sdks\Microsoft.NET.Sdk\build\Microsoft.NET.Sdk.targets(92,5): error : Cannot find project info for 'C:\_projects\
misc\Html2Markdown\src\Html2Markdown\Html2Markdown.csproj'. This can indicate a missing project reference. [C:\_projects\misc\Html2Markdown\test\Ht
ml2Markdown.Test\Html2Markdown.Test.csproj]
    0 Warning(s)
    2 Error(s)

Environment data

dotnet --info output:

.NET Command Line Tools (1.0.4)

Product Information:
Version:            1.0.4
Commit SHA-1 hash:  af1e6684fd

Runtime Environment:
OS Name:     Windows
OS Version:  10.0.14393
OS Platform: Windows
RID:         win10-x64
Base Path:   C:\Program Files\dotnet\sdk\1.0.4

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:3
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

22reactions
dasMullicommented, Dec 27, 2017

You can replicate build and revision wildcards by implementing roslyn’s version pattern logic in pure MSBuild:

<PropertyGroup>
  <Build>$([System.DateTime]::op_Subtraction($([System.DateTime]::get_Now().get_Date()),$([System.DateTime]::new(2000,1,1))).get_TotalDays())</Build>
  <Revision>$([MSBuild]::Divide($([System.DateTime]::get_Now().get_TimeOfDay().get_TotalSeconds()), 2).ToString('F0'))</Revision>
  <Version>1.2.$(Build).$(Revision)</Version>
</PropertyGroup>
0reactions
SoftwareDreamercommented, Nov 6, 2019

I fixed it btw with

    <PropertyGroup Condition="'$(DOTNET_RUNNING_IN_CONTAINER)' == 'true'">
        <Build>$([System.DateTime]::op_Subtraction($([System.DateTime]::get_Now().get_Date()),$([System.DateTime]::new(2000,1,1))).get_TotalDays())</Build>
        <Revision>$([MSBuild]::Divide($([System.DateTime]::get_Now().get_TimeOfDay().get_TotalSeconds()), 2).ToString('F0'))</Revision>
        <Version>1.0.$(Build).$(Revision)</Version>
    </PropertyGroup>

So for us it’s fixed, once we build in any of the official SDK image DOTNET_RUNNING_IN_CONTAINER is set… so it works even with the VS bug

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to have an auto incrementing version number (Visual ...
This will increment the build number every time you build the project regardless of the selected configuration (i.e. Debug|Release), and it will ...
Read more >
Auto Version Increment
Getting Started · Ctrl + Alt + W for Windows & Linux & Cmd + Alt + W for Mac (Global command, update...
Read more >
Increase version number automatically with git | Medium
Step 1: pick the file to update automatically​​ As you may have noticed, the goal is to build a string that concatenates the...
Read more >
How to make auto-incrementing build number ? : r/vscode
Most of them will push some sort of build number into an environment variable that you can then consume in your build script....
Read more >
Auto-generate version numbers - Programming Questions
Is there any way for me to generate automatically a version number in a sketch? Like something to count lines or number of...
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