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.

Could this work on .NET projects?

See original GitHub issue

I know most of this is dependent on your git commits. But where it tracks your version depends on if you have a package.json or composer.json. So what if you wanted to use standard-version on a .NET C#, VB.net, or even SQL project? These projects use a .vbproj, .csproj, .sqlproj, file for tracking version numbers. Is there a possibility of standard-version supporting these types of projects too?

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

8reactions
Yanal-Yvescommented, Sep 17, 2020

You could use a custom updater. Here’s what I did for my .net core 3.1 C# projects:

  1. In the same folder as your .versionrc file, add a file named dotnet-version-updater.js:
module.exports.readVersion = function (contents) {
  const regEx = /<Version>(.*)<\/Version>/g;
  const arr = regEx.exec(contents);
  if (arr !== null && arr.length === 2) {
    return arr[1];
  }

  return "";
}

module.exports.writeVersion = function (contents, version) {
  return contents.replace(/<Version>.*<\/Version>/, '<Version>' + version + '</Version>');
}
  1. Then in your .versionrc file:
{
...
  "bumpFiles": [
      ...
      { "filename": "PATH_TO_YOUR_CSPROJ_1", "updater":"dotnet-version-updater.js" },
      { "filename": "PATH_TO_YOUR_CSPROJ_2", "updater":"dotnet-version-updater.js" },
      ...
      { "filename": "PATH_TO_YOUR_CSPROJ_N", "updater":"dotnet-version-updater.js" },
      ...
  ]
  ...
}
  1. Make sure all your .csproj files have a Version tag, ex:
  <PropertyGroup>
    <TargetFramework>netcoreapp3.1</TargetFramework>
    <Version>1.2.3</Version>
  </PropertyGroup>

The dotnet-version-updater.js is simply using a regex, so if the Version tag doesn’t exist, it won’t be able to bump the file and won’t create the Version tag. One improvment would be to make dotnet-version-updater.js add the Version tag if it doesn’t exist.

I hope that helps.

3reactions
jbottiglierocommented, Jul 18, 2019

Hey! Thanks for the report. This has been asked for a few times (in slightly different ways), it’s a feature (support for any file/project type) that I’d love to get implemented and have started to work toward in #372

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Boot-strap and Create .NET Projects - Toptal
To create .NET project from scratch, simply using Visual Studio Wizard is good enough most of the time. However, the default project settings...
Read more >
Port from .NET Framework to .NET 6 - .NET Core
NET Framework libraries doesn't work for all projects, such as if the library uses WPF APIs, but it does unblock many porting scenarios....
Read more >
The Good and the Bad of .NET Framework Programming
Apart from being the final step of the unification, .NET 6 can boast of: Better performance with decreased project execution time, latency time, ......
Read more >
Another 5 .NET projects that deserve more attention - YouTube
Check out my courses and use code OPEN15 for a 15% discount: https://nickchapsas.comBecome a Patreon and get source code access: ...
Read more >
Modernising .NET projects for .NET Core and beyond!
NET Core does not run on the .NET Framework and vice-versa. To deal with this issue, Microsoft developed the .NET Standard - a...
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