NSB ScriptBuilderTask cannot resolve assembly of own nuget package

112 Views Asked by At

We have a microservice architecture and share some code between our services using a nuget package called "HC.Framework".

When i try to build a solution that is using this nuget package (that has all the configs for NSB and stuff) i get the following exception:

1>MSBUILD : error : SqlPersistenceTask: An unhandled exception occurred:
1>MSBUILD : error : Exception:
1>MSBUILD : error : Failed to resolve assembly: 'HC.Framework, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'
1>MSBUILD : error : StackTrace:
1>MSBUILD : error :    at Mono.Cecil.BaseAssemblyResolver.Resolve(AssemblyNameReference name, ReaderParameters parameters)
1>MSBUILD : error :    at Mono.Cecil.DefaultAssemblyResolver.Resolve(AssemblyNameReference name)
1>MSBUILD : error :    at Mono.Cecil.MetadataResolver.Resolve(TypeReference type)
1>MSBUILD : error :    at Mono.Cecil.TypeReference.Resolve()
1>MSBUILD : error :    at CecilExtensions.FindInTypeHierarchy[T](TypeDefinition type, Func`2 search)
1>MSBUILD : error :    at SagaDefinitionReader.TryGetCoreSagaDefinition(TypeDefinition type, SagaDefinition& definition)
1>MSBUILD : error :    at AllSagaDefinitionReader.GetSagas(Action`2 logger)
1>MSBUILD : error :    at SagaWriter.WriteScripts(BuildSqlDialect dialect)
1>MSBUILD : error :    at ScriptGenerator.Generate()
1>MSBUILD : error :    at InnerTask.Execute()
1>MSBUILD : error :    at NServiceBus.Persistence.Sql.SqlPersistenceScriptBuilderTask.Execute()
1>MSBUILD : error : Source:
1>MSBUILD : error : NServiceBus.Persistence.Sql.ScriptBuilderTask
1>MSBUILD : error :

I'm not sure what the issue is here? Below is a snippet of a saga class:

using System.Threading.Tasks;
using NServiceBus;
using HC.Swatson.Processor.Saga.Command;
using HC.Framework.NSB;
using HC.Swatson.Application.Command;
using HC.Integration.ReplyMessages.Sendgrid;

namespace HC.Swatson.Processor.Saga
{
    public class SendWrongPredictionEmailSD : BaseSagaData<SendWrongPredictionEmailCMD>
    {
        public SendWrongPredictionEmailSD() : base(totalSteps: 2) { }
    }

    public class SendWrongPredictionEmailSAGA :
        Saga<SendWrongPredictionEmailSD>,
        IAmStartedByMessages<SendWrongPredictionEmailCMD>,
        IHandleMessages<ReplyMessage<SendWrongPredictionEmail2CMD>>,
        IHandleMessages<EmailHasBeenSentRM>
    {
...

We also specify the following configuration in the HC.Framework package:

[assembly: SqlPersistenceSettings(
    MsSqlServerScripts = true,
    MySqlScripts = false,
    OracleScripts = false,
    PostgreSqlScripts = false,
    ProduceOutboxScripts = true,
    ProduceSagaScripts = true,
    ProduceSubscriptionScripts = true,
    ProduceTimeoutScripts = true
    )]

The only maybe helpfull info i can think of is that we are upgrading from .net5 to 6, this might be related?

Any ideas on why this might ocure is welcome!

EDIT:

So after some more looking into it. If i run the scripts manually with the dotnet tool the scripts generate fine. This seems to be a issue/bug with NSB so i've openend a ticket with them.

1

There are 1 best solutions below

2
On

Just install NServiceBus in your project where you want to use it