3

I'm quite familiar with NuGet package generation, but this is the first time I'm trying to generate a package with a Microsoft.NET.Sdk.Web sdk type instead of the typical Microsoft.NET.Sdk.

I know this is probably uncommon, but I need this type of sdk to reference AspNetCore specific types (SignalR hubs) which are not available in the classic sdk format.

I always set these properties in my .csproj file to have the nuget package (.nupkg file) generated:

  1. PackageId
  2. Authors
  3. Company
  4. Version
  5. Target frameworks
  6. GeneratePackageOnBuild (true)
  7. GenerateDocumentationFile (true)
  8. DebugSymbols (true)
  9. DebugType (full)

Usually, this is enough to have my package properly created - but not with Microsoft.NET.Sdk.Web sdk format. I played a bit to create test scenarios and isolated the issue, I'm pretty sure this depends on the sdk format and not something else.

Expected behavior: .nupkg file generated in output directory (bin/Debug).

Actual behavior: Project builds but no .nupkg file is generated.

Has anyone already faced this issue?

3
  • What exactly went wrong? What is the result instead of the expected? Commented Nov 29, 2024 at 13:59
  • 1
    @Fildor you're right, I updated my question. Commented Nov 29, 2024 at 14:13
  • 1
    "but I need this type of sdk to reference AspNetCore specific types" Can't you add a reference to the assembly of the types you need? Commented Nov 29, 2024 at 14:56

1 Answer 1

2

Try changing back to the Microsoft.NET.Sdk and adding the FrameworkReference element:

<ItemGroup>
    <FrameworkReference Include="Microsoft.AspNetCore.App" />
</ItemGroup>

See the Use ASP.NET Core APIs in a class library doc.

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you, this solved the problem. I also found another workaround while reading the output log from build process: add <IsPackable>true</IsPackable> to my .csproj also worked.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.