Skip to content
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

how version is created #87

Closed
asulwer opened this issue Nov 15, 2024 · 6 comments
Closed

how version is created #87

asulwer opened this issue Nov 15, 2024 · 6 comments
Labels
enhancement New feature or request

Comments

@asulwer
Copy link
Owner

asulwer commented Nov 15, 2024

@RenanCarlosPereira

the version is created manually. i would like to change how it is generated. example 7.0.(build date)

@asulwer asulwer added the enhancement New feature or request label Nov 15, 2024
@RenanCarlosPereira
Copy link
Collaborator

Once you push a tag it creates the version automatically. We can change it in the workflows

@asulwer
Copy link
Owner Author

asulwer commented Nov 16, 2024

i meant in the project file

@samabos
Copy link

samabos commented Feb 5, 2025

Hi @asulwer, need more information on this requirement, do you wish to use the project version below and append the build date as the package version?
Image

@asulwer
Copy link
Owner Author

asulwer commented Feb 5, 2025

@samabos i have a solution to this, just have not implemented it yet. i created a separate project which sets the version number automatically.

namespace VersionTask
{
    public class VersionTask : Task
    {
        [Required]
        public string FileName { get; set; }
        [Required]
        public string Version { get; set; }
        [Required]
        public string Attributes { get; set; }

        public override bool Execute()
        {
            bool bFlag = false;

            try
            {
                if (File.Exists(FileName) && Attributes.Contains(':'))
                {
                    XmlDocument doc = new XmlDocument();
                    doc.Load(FileName);
                    Log.LogMessage($"Loaded File: {FileName}");

                    XmlNode root = doc.DocumentElement;

                    foreach (string attr in Attributes.Split(':'))
                    {
                        root.SelectSingleNode($"/Project/PropertyGroup/{attr}").InnerText = Version;
                        Log.LogMessage($"Edited Node: {attr}");
                    }

                    doc.Save(FileName);
                    Log.LogMessage($"Saved File: {FileName}");

                    bFlag = true;
                }
            }
            catch (Exception ex)
            {
                Log.LogErrorFromException(ex, true);
            }

            return bFlag;
        }
    }
}

@RenanCarlosPereira
Copy link
Collaborator

RenanCarlosPereira commented Feb 12, 2025

You don’t need to create a side project just to handle versioning in GitHub Actions for your .csproj and NuGet package. You can integrate versioning directly into your existing project by updating the .csproj file dynamically during your CI/CD pipeline.

actually its already like that, check the pipeline

we could remove the version from the csproj if needed

@asulwer
Copy link
Owner Author

asulwer commented Feb 12, 2025

@RenanCarlosPereira another project of mine, not on github, i use a separate project to adjust the version number. i provided the code here from that project

@asulwer asulwer closed this as completed Feb 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants