Skip to content
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

SecurityToken is not found by .NET Framework project after upgrade of System.ServiceModel.Primitives from 4.10.3 to 8.1.1 in netstandard2.0 project #5722

Open
vgriph opened this issue Jan 3, 2025 · 2 comments

Comments

@vgriph
Copy link

vgriph commented Jan 3, 2025

Describe the bug
Version 8.1 of the System.ServiceModel.Primitives brings back netstandard and .NET Framework support to the System.ServiceModel.Primitives package, after it was removed in version 6.0.0. However, after updating the version from 4.10.3 to 8.1.1, when building a .NET Framework project consuming a .NET standard project, exposing the SecurityTopken type in a return parameter, the .NET framework project fails to build with

Error CS7069: Reference to type 'SecurityToken' claims it is defined in 'System.ServiceModel.Primitives', but it could not be found

To Reproduce
Steps to reproduce the behavior:
Build the attached solution: SecurityTokenNotFound.zip

Expected behavior
The solution should build correctly, as it does when downgrading the System.ServiceModel.Primitives package reference to 4.10.3

@vgriph
Copy link
Author

vgriph commented Jan 3, 2025

This seems to be cause by the reference assembly for .NET Framework 4.6.2 (ref\net462\System.ServciceModel.Primitives.dll) not containing the type forwarders.

@vgriph
Copy link
Author

vgriph commented Jan 3, 2025

Found a work-around by adding the following target to the .NET Framework project:

	<Target Name="DontUseSystemServiceModelPrimitivesReferenceAssembly" BeforeTargets="ResolveLockFileReferences">
		<ItemGroup>
			<ResolvedCompileFileDefinitions 
				Remove="@(ResolvedCompileFileDefinitions)"
				Condition="'%(PathInPackage)' == 'ref/net462/System.ServiceModel.Primitives.dll' AND '%(NuGetPackageId)' == 'System.ServiceModel.Primitives'" />
			<ResolvedCompileFileDefinitions
				Include="@(RuntimeCopyLocalItems)"
				Condition="'%(PathInPackage)' == 'lib/net462/System.ServiceModel.Primitives.dll' AND '%(NuGetPackageId)' == 'System.ServiceModel.Primitives'" />
		</ItemGroup>
	</Target>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant