New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Could this work on .NET projects? #402
Comments
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 |
Hello @jbottigliero. There are to many project types to support :) Is there an option to print/set variable with version number without doing any updates or commits? It will be ideal option for all CI scenarios as this systems already have tasks for bumping version numbers for various projects, but as I found, they still don't support Semantic Commits. |
@FixRM – if I'm not mistaking, I think what you are looking for would be a combination of the existing Your specific mention of "[...] already have tasks for bumping version numbers for various projects [...]" does have me thinking of potentially broadening support for executables instead of just Javascript-based "package file updaters". |
You can set this up manually by using the If anyone's interested the implementation I've got so far is detailed below. Note The below assumes a folder structure like:
{
"scripts": {
"postbump": "node ./scripts/sync-version.js && git add src/{project-name}/{project-name}.csproj"
}
}
/**
* sync-version.js: Utility script to sync version changes from package.json --> csharp project.
*/
const replace = require("replace-in-file");
const npm = require("../package.json");
// Configure replace-in-file options.
const options = {
files: "src/**/*.csproj",
from: /<Version>(.+)<\/Version>/g,
to: `<Version>${npm.version}</Version>`
};
// Perform the replacement.
replace(options).catch(error => {
console.error("Failed to synchronize npm version:", error);
});
console.log("[INFO] finished synchronizing version"); And that should do it. A working implementation of this can be found in one of my current projects Muster.Core if you want something concrete. If we do get support for doing this through standard-version then there shouldn't be a need to go through this process, but a single extra js file and a line of config is acceptable for me at the moment. |
Thanks @isaac-brown, Not sure how can it help to avoid tagging and pushing something to master. |
@isaac-brown, now i see, you are sending skip parameters. By the way, you don't need .versionrc file, you can put scripts to package.json under "standard-version" node |
You could use a custom updater. Here's what I did for my .net core 3.1 C# projects:
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>');
}
{
...
"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" },
...
]
...
}
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<Version>1.2.3</Version>
</PropertyGroup> The I hope that helps. |
We are using it for .NET here: https://github.com/GetStream/stream-chat-net/blob/master/.github/workflows/initiate_release.yml |
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?The text was updated successfully, but these errors were encountered: