Particular / NServiceBus.AzureFunctions.Worker.ServiceBus

Process messages in AzureFunctions using the Azure Service Bus trigger and the NServiceBus message pipeline.
Other
6 stars 3 forks source link

Could not load file or assembly 'Microsoft.CodeAnalysis, Version=3.10.0.0, #26

Closed johnkors closed 2 years ago

johnkors commented 2 years ago

Hi, thanks for letting us test the previews! Getting this warning during build:

CSC : warning CS8032: An instance of analyzer NServiceBus.AzureFunctions.SourceGenerator.TriggerFunctionGenerator 
cannot be created from /Users/johnkors/.nuget/packages/nservicebus.azurefunctions.worker.servicebus/1.0.0-alpha.1/analyzers/dotnet/cs/NServiceBus.AzureFunctions.Worker.SourceGenerator.dll : 
Could not load file or assembly 'Microsoft.CodeAnalysis, Version=3.10.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. 
The system cannot find the file specified.. [/Users/johnkors/kode/blank/fplbot-org/fplbot/src/FplBot.Functions/FplBot.Functions.csproj]

Anything to worry about?

Csproj I'm building:

<PropertyGroup>
    <TargetFramework>net5.0</TargetFramework>
    <AzureFunctionsVersion>v3</AzureFunctionsVersion>
    <OutputType>Exe</OutputType>
    <LangVersion>latest</LangVersion>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Http" Version="3.*" />
    <PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="1.*" OutputItemType="Analyzer" />
    <PackageReference Include="Microsoft.Azure.Functions.Worker" Version="1.*" />
    <PackageReference Include="NServiceBus.AzureFunctions.Worker.ServiceBus" Version="1.0.0-alpha.1" />
  </ItemGroup>
johnkors commented 2 years ago

Sorry, I think this was related to me using the latest .NET 6 Preview SDK. Switching back to .NET 5 SDK helped.

johnkors commented 2 years ago

I think this at least warrants a clear recommendation somewhere to do treat CS8032 as an error . I've now seen this error both with the 5.0.100 SDK as well as the .NET 6.0 Preview 7 SDKs.

The impact of this being silent is that no ServiceBus triggers are generated, and you would not know unless you looked thru raw logs. Build and deploys work fine, but do not show up in Azure.

Maybe document and recommend <WarningsAsErrors>CS8032</WarningsAsErrors> when using the autogenerated triggers?

timbussmann commented 2 years ago

I've raised #32 specifically to improve the surfacing of trigger-generation failures so we can focus this issue on the reason for the loading failure.

So you've seen this issue showing up both with the 5.0.100 SDK as well as the .NET 6.0 Preview 7 SDKs? DId I understand correctly that 5.0.400 did work?

johnkors commented 2 years ago

Yes, exactly. And by the looks of this doc, it looks like there is a dependency on the .NET 3.1 SDK somewhere. So it's a bit of a mess at the moment, but that's with the Azure Function tooling team though.

Note: Currently you need both the .NET Core 3.1 and .NET 6.0 SDKs installed to build isolated function apps. You only need .NET 6.0 to run the apps.

Not having the blessed combo of SDKs installed made the source generation not work, and fail silently.

5.0.400 did not have any issues.

timbussmann commented 2 years ago

I've dug a little bit deeper and it seems the minimum .NET SDK version required is 5.0.300. I've raised a docs PR to explicitly mention this requirement when working with this package: https://github.com/Particular/docs.particular.net/pull/5495.

andreasohlund commented 2 years ago

With https://github.com/Particular/docs.particular.net/pull/5495 I think we can close this as resolved

johnkors commented 2 years ago

I'd say it's not resolved, but tracking moved to #32 . It's still an issue - but now just documented in Particular/docs.particular.net#5495.

andreasohlund commented 2 years ago

Good catch, that is correct