Closed espenrl closed 2 years ago
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/'))
It works. I've added the change.
Added generation time reference: <redacted>\.nuget\packages\microsoft.csharp\4.7.0\ref\netstandard2.0\Microsoft.CSharp.dll
Added generation time reference: <redacted>\.nuget\packages\microsoft.csharp\4.7.0\lib\netstandard2.0\Microsoft.CSharp.dll
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.
It happened due to the fact that the latest version of NSwag had problems that were not solved for a long time: https://github.com/RicoSuter/NSwag/issues/4012 https://github.com/RicoSuter/NJsonSchema/pull/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.
I see, you're following the versioning of NSwag. Makes sense.
There is a issue with NuGet packages which contains ref assemblies like
Microsoft.CSharp
andSystem.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 theseref 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 usingdotnet build
becauseMicrosoft.CSharp.dll
can't be loaded. I've tested and verified thatH.NSwag.Generator
works using this fix fordotnet build
.