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

Do not output ref assemblies #1

Merged
merged 2 commits into from
Nov 1, 2022

Conversation

espenrl
Copy link

@espenrl espenrl commented Nov 1, 2022

There is a issue with NuGet packages which contains ref assemblies like Microsoft.CSharp and System.Runtime.Serialization.Primitives. Ref assemblies are only for compilation, and not for runtime execution. I've learned a lot about .NET Standard, NuGet and MSBuild during the last hours. :)

ResolvedCompileFileDefinitions points to these ref files, and my fix is as simple as replacing \ref\ with \lib\. Ref and lib should always come in pair, so it should be an okay solution to the problem.

I do not know if MSBuild ever will produce forward slashes. The code only handles backward slashes.

Fixes H.NSwag.Generator

I'm using H.NSwag.Generator which is a great tool. I can only build using full MSBuild. It fails using dotnet build because Microsoft.CSharp.dll can't be loaded. I've tested and verified that H.NSwag.Generator works using this fix for dotnet build.

@HavenDV
Copy link
Owner

HavenDV commented Nov 1, 2022

Hello. Thanks a lot for this PR, I didn't know about ref directories in nuget package
Can you quickly test if this will work?
@(ResolvedCompileFileDefinitionsWithoutSystem->Replace('\ref\', '\lib\')->Replace('/ref/', '/lib/'))

@espenrl
Copy link
Author

espenrl commented Nov 1, 2022

It works. I've added the change.

without fix

Added generation time reference: <redacted>\.nuget\packages\microsoft.csharp\4.7.0\ref\netstandard2.0\Microsoft.CSharp.dll

with fix

Added generation time reference: <redacted>\.nuget\packages\microsoft.csharp\4.7.0\lib\netstandard2.0\Microsoft.CSharp.dll

@espenrl
Copy link
Author

espenrl commented Nov 1, 2022

Oh, btw. It's a bit confusing that the latest packages for H.NSwag.Generator are in the 13.15.x range, while the highest version is in the 13.16.x range. Dependabot always suggest me to update, and I never really know if there is a new 13.15.x release. It would have been awesome if this was sorted out.

image

@HavenDV
Copy link
Owner

HavenDV commented Nov 1, 2022

It happened due to the fact that the latest version of NSwag had problems that were not solved for a long time:
RicoSuter/NSwag#4012
RicoSuter/NJsonSchema#1522
I think this issue is already settled, at least 4 months to accept the PR, and I will release a new version already according to the latest version of NSwag after accepting this PR.

@espenrl
Copy link
Author

espenrl commented Nov 1, 2022

I see, you're following the versioning of NSwag. Makes sense.

@HavenDV HavenDV merged commit cde2ba7 into HavenDV:main Nov 1, 2022
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

Successfully merging this pull request may close these issues.

2 participants