Aaron. S
Aaron. S

Reputation: 527

Visual Studio 2022 release/debug builds fine, error during Publish

Visual Studio 2022 v17.8.6

In the solution explorer I choose Publish for my WPF app. FolderPublish worked fine until upgrading to Net8 from Net7. These errors popped up since upgrading the project or VS

The type or namespace name 'HashSet<>' could not be found (are you missing a using directive or an assembly reference?)

I am not personally referencing HashSet in my code, anywhere. Maybe a Nuget package is??

this next error is repeated 6 times. adding that line to my project solved that issue. why is it suddenly appearing in the first place?

The 'interceptors' experimental feature is not enabled in this namespace. Add '$(InterceptorsPreviewNamespaces);Microsoft.Extensions.Configuration.Binder.SourceGeneration' to your project.

I have a console project that also was upgraded from Net7 to Net8 and publishing works fine for it. it targets the same Nuget packages as the failing WPF application. Building works and so does running the app.

Upvotes: 3

Views: 1299

Answers (1)

spiral
spiral

Reputation: 117

I was having a similar problem. Changed the publish settings as follows

  • Deployment Mode: Self contained -> change to Framework Dependent
  • Target Runtime: win-x64 -> change to Portable

It publishes now, not exactly the settings I wanted... more of a work around than a solution.

UPDATE:

Adding this to the .csproj file also fixed it.

<InterceptorsPreviewNamespaces>$(InterceptorsPreviewNamespaces);Microsoft.Extensions.Configuration.Binder.SourceGeneration</InterceptorsPreviewNamespaces>

Upvotes: 6

Related Questions