-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
[Broken Build]: FluentMigrator.MSBuild sample won't work on net8.0 #10750
Comments
After debugging this for another full day,
There has to be some obscure scenario in the .NET runtime causing this woe I am facing? The two interfaces are: FluentMigrator.IMigration, FluentMigrator.Abstractions, Version=6.1.4.0, Culture=neutral, PublicKeyToken=aacfc7de5acabf05 FluentMigrator.IMigration, FluentMigrator.Abstractions, Version=6.1.4.0, Culture=neutral, PublicKeyToken=aacfc7de5acabf05 |
I still can't figure this out. This is just bizarre. I see no evidence this shouldn't be working. I added a DirtyAssemblyResolveHelper to the FluentMigrator.MSBuild project, and it doesn't fix whatever the issue is. I can make DirtyAssemblyResolveHelper stateful and inject an ILogger, I suppose, and trace out any redirects to see what is or isn't being handled. (Functionally, this is simpler than assembly fusion logging, as it would only really come into play calling this one task, vs the entire msbuild build chain) |
Thank you @jzabroski for reporting the issue Can you help us in focusing the investigation via providing:
Thank you |
This issue is marked as stale because feedback has been requested for 30 days with no response. Please respond within 14 days or this issue will be closed due to inactivity. |
Issue Description
FluentMigrator.MSBuild version 6.1.4 is packaged following guidance here: this project references nuget package FluentMigrator.MSBuild, which was packaged following the guidance here: https://learn.microsoft.com/en-us/visualstudio/msbuild/tutorial-custom-task-code-generation?view=vs-2022#create-a-nuget-package
The problem is that as I am loading an assembly as part of the target, for some reason the reflection calls are failing, even though it looks to me like all the assembly versions match (6.1.4). - This works on .NET Framework 4.8 (TFM net48), but fails on net8.0
The other thing I am looking at is GenerateTemporaryTargetAssemblyTask
Steps to Reproduce
Sample project here: https://github.com/fluentmigrator/fluentmigrator/tree/main/samples/FluentMigrator.Example.MSBuild
To run:
dotnet.exe msbuild .\samples\FluentMigrator.Example.MSBuild\SampleMigrator.csproj
Requires a local database server to run - SQL Server localdb is fine. If using localdb, you just need to update the connection string appropriately and create an empty FluentMigratorExample database, then you can run the target as described above.
I ran it using:
and
Note, this works correctly with a .NET CLI tool - the only difference is the entrypoint - one is MSBuild custom task, the other is a CLI tool. They share much of the same code.
Expected Behavior
Migrations run - no red ink errors should occur - the output should say something similar to the equivalent FluentMigrator.DotNet.Cli tool output, as the two packages use the same TaskExecutor and basically the same Microsoft DI configuration.
Actual Behavior
The error I get is:
Typically, this is not a hard error message to figure out and I've documented in our FAQ the common causes. However, what stumps me here is I checked all the common causes and they're not the issue.
Ask us questions
1. Is there a bridge between MSBuild's ILogger and Microsoft DI ILogger I can use? Much of the logic that is failing is not in my MSBuild assembly, but in a common shared assembly that uses Microsoft DI ILogger instead. Having a shim I can wire up would make it a lot easier to debug this problem.Is there something I am missing with running dotnet.exe msbuild that could be a problem here?
Could how I am publishing the FluentMigrator.MSBuild task be a problem? Like, somehow it embeds the wrong reference to an assembly? How would I diagnose that?
Would [GenerateTemporaryTargetAssembly task[(https://learn.microsoft.com/en-us/visualstudio/msbuild/generatetemporarytargetassembly-task?view=vs-2022) be a better approach? I've never done it so I am a little intimidated it will be a time suck that goes nowhere. There's limited samples I can find that approximate what I am doing.
The text was updated successfully, but these errors were encountered: