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

Allow setting Release via an MSBuild property #3443

Closed
ericsampson opened this issue Jun 21, 2024 · 7 comments
Closed

Allow setting Release via an MSBuild property #3443

ericsampson opened this issue Jun 21, 2024 · 7 comments

Comments

@ericsampson
Copy link

Problem Statement

Right now the Release value is constructed via other properties (if not set as an env var), but there are situations where it would be easier to allow the user to explicitly stamp the desired Release as a SentryRelease MSBuild prop.

Solution Brainstorm

No response

@bitsandfoxes
Copy link
Contributor

You can set the SentryRelease from code through the options. Does that not work for you?

@ericsampson
Copy link
Author

You can set the SentryRelease from code through the options. Does that not work for you?

No, because that doesn't work nicely in our CI pipeline. I'd like to be able to pass in the SentryRelease as an msbuild property argument to our dotnet publish command.

Does that make sense? Thanks!

@getsantry getsantry bot moved this to Waiting for: Product Owner in GitHub Issues with 👀 3 Jun 24, 2024
@bitsandfoxes
Copy link
Contributor

I see your point. You could set a custom release attribute to be available at runtime.
It would look a little something like this

<Target Name="EnsureCustomRelease" BeforeTargets="BeforeBuild">
  <MakeDir Directories="Properties" Condition="!Exists('Properties')" />
  <WriteLinesToFile File="Properties\CustomReleaseInfo.cs" Lines="using System.Reflection%3b" Overwrite="true" />
  <WriteLinesToFile File="Properties\CustomReleaseInfo.cs" Lines="[assembly: AssemblyMetadata(&quot;CustomRelease&quot;, &quot;$(CustomRelease)&quot;)]" Overwrite="false" />
</Target>

That can be retrieved like so

var assembly = Assembly.GetExecutingAssembly();
var customReleaseAttribute = assembly
    .GetCustomAttributes<AssemblyMetadataAttribute>()
    .FirstOrDefault(a => a.Key == "CustomRelease")
    ?.Value;

And you can set it via commandline dotnet publish -p:CustomRelease=1.0.0.
Would that unblock you?

@jamescrosswell
Copy link
Collaborator

This seems very similar to:

Is there anything we're suggesting in this issue that isn't already covered in the issue above?

@ericsampson
Copy link
Author

@jamescrosswell I wasn't sure if the issue that you linked to included adding a new MSBuild property for SentryRelease.
If so, maybe we could update that issue's "spec" to call that out, and then this issue could be closed?

@getsantry getsantry bot moved this to Waiting for: Product Owner in GitHub Issues with 👀 3 Jul 1, 2024
@bitsandfoxes
Copy link
Contributor

Added this here to keep track of it. Thanks @ericsampson for all the valuable input! It's much appreciated.

@ericsampson
Copy link
Author

thank you @bitsandfoxes <3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Archived in project
Development

No branches or pull requests

3 participants