-
-
Notifications
You must be signed in to change notification settings - Fork 25
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
Setting GenerateAssemblyInfo=false stops source generator from running #407
Comments
Hi there! Some questions:
Thanks! |
closing/reopening make no different and also deleting the obj nuget folder makes no difference. This is a compile error as the generated class is not found I can't compile the project at all no matter if I try it from VS2022 or cli with dotnet. |
Could you share which package you're using? ThisAssembly.AssemblyInfo or ThisAssembly (metadata package)? |
I use this one: https://www.nuget.org/packages/ThisAssembly.AssemblyInfo/2.0.0 and before updating I was using the 1.5.0 version which is now unlisted? https://www.nuget.org/packages/ThisAssembly.AssemblyInfo/1.5.0 I'm now out of office for the rest of the day, I'll try to compare the build with 1.5.0 and 2.0.0 tomorrow. |
Yeah, I have unlisted 1.5 in favor of 2.0. |
ok, comparing 1.5.0 and 2.0.0 shows that 2.0.0 nuget misses the actual generator dll And I'm not allowed to provide such a binlog (GDPR). |
ok, after looking at the commits (which are horrible as there are a lot of meaningless commits "Bump files with dotnet-file sync" which is awfull to see what commits do, you need to check every commit what is changed) I found this commit. This explains the dependency on |
Could you please create a repro project? I simply cannot reproduce your issue as-is. The fact that those targets are greyed out do not indicate much (could have run previously already, for example). Without either a repro project or a binlog, there isn't much I can do :(
Not really, you can just look at commits that actually affect the specific project folder or files. |
I've created a demo that works fine with 1.5.0 and fails with 2.0.3. It is an empty .net 8 WinForms application but includes all reference nugets as in my real application but it depends on subversion for version control. You need to checkout the code from the repo with svn/TortoiseSVN and open the sln in trunk ThisAssembly.AssemblyInfo.Demo_SVN_Repo.zip If I downgrade the package to 1.5.0 I get the generated files. |
Did you have some time to look at it? You need use |
Able to reproduce as a first party consumer and with `dotnet build` in CLI. |
This seems to only happen when upgrading from a previous version. Remove |
Roslyn does heavy caching of intermediate files. I'd suggest deleting bin/obj recursively and try again. I do not have or use svn to test this locally from the provided zip. I doubt it has anything to do with source control, to a simple zip of the actual sources should be enough if it does repro. |
As already said, clearing obj/bin makes no difference. without svn the code doesn't compile as I've added Unclassified.NetRevisionTask I also use in my project. You wanted all references, you get all references in the demo |
ok, I found the cause. Setting |
That's great actionable investigation, thanks! I'll look into it ASAP. |
We were missing this since the SDK defaults the specific attributes to `true` only if the overall flag `GenerateAssemblyInfo` is `true`. We change that in our targets, but without forcing `GenerateAssemblyInfo=true`. This allows to turn off codegen, but still get the attributes as items. Fixes #407
Got the fix 💪 #422 |
We were missing this since the SDK defaults the specific attributes to `true` only if the overall flag `GenerateAssemblyInfo` is `true`. We change that in our targets, but without forcing `GenerateAssemblyInfo=true`. This allows to turn off codegen, but still get the attributes as items. Fixes #407
nope, still the same error. The translation to constants runs but generates crap (Company gets project name, version is 1.0.0.0 not my version from Unclassified.NetRevisionTask) so the default values. And the Copyright, Description from AssemblyInfo.cs are not translated and so I still have compile error And when I update the nuget in my demo project to 2.0.4 I get this error:
|
It looks like whatever you're using is not playing nice and is generating a non-partial ThisAssembly. Plz bring the issue to them. Without a repro, it's kinda impossible to see what you see. All my tests and daily usage shows it's working as designed. I have never used that Unclassidified thing. |
I've posted a repro which you ignore the whole time. I'll stick on 1.5.0 which works and ignore all newer updates. |
and your "fix" is to ignore my configured GenerateAssemblyInfo value and set the values to the data which the SDK sets when GenerateAssemblyInfo is true. And this is what I DON'T want. I set the value to false for reasons! |
That is not something I can work off of as a repro. Plz provide a github repo if that is easier for you. Could you elaborate on why it's what you DON'T WANT, what I did? I studied the SDK targets carefully and there's no side effect from my fix. You might disagree with how I fixed it, but that's a different matter. What side effect are you seeing that is problematic? Please provide a clean repro I can simply clone or download (without having to install any software), and I can look at it. |
Also, I'd be more than happy to review a PR that fixes it in a better way for your scenario. |
Again, there is a sideeffect, your changes causes that data are read from the csproj and no longer from my AssemblyInfo.cs and this causes issues with my consumed Unclassified.NetRevisionTask package. It doesn't support this and the subversion revision is not added to the version. I have to do this as there is no Subversion SourceLink provider , so I need to add the SVN revision to the version number to see which version the user is running so that I can checkout this revision to debug the issue. So I MUST set GenerateAssemblyInfo to false. And as I use Subversion, putting this on Github is useless 🤦. I debugged the issue, found the casue, provided you a repro and you only complain and complain. I've add the working |
Well, I guess you can also report to that Unclassified.NetRevisionTask package that they are incompatible with this package. As I mentioned, I'd gladly take a PR if this is critical for you. I don't have the bandwidth to do this for free, and this is the first and only time someone ever reported such an issue. Thanks. |
Describe the Bug
After Updating ThisAssembly to from 1.5.0 to 2.0.0 I can no longer access the ThisAssembly.Info properties like
ThisAssembly.Info.Description
As they come from 3rd party tools, not from my project:
Steps to Reproduce
update from "ThisAssembly.AssemblyInfo" to 2.0:
<PackageReference Include="ThisAssembly.AssemblyInfo" Version="2.0.0">
Expected Behavior
code can be called
var Description = ThisAssembly.Info.Description;
fine as in 1.5.0In my csproj I have set thoise 2 entries:
and I no longer see the genereted
ThisAssembly.AssemblyInfo.g.cs
file only theApplicationConfiguration.g.cs
which includes the generated calls forApplicationConfiguration.Initialize();
The text was updated successfully, but these errors were encountered: