toddams / RazorLight

Template engine based on Microsoft's Razor parsing engine for .NET Core
Apache License 2.0
1.51k stars 260 forks source link

Can't build project referencing 2.0.0-beta* on MacOS #350

Closed georgiosd closed 3 years ago

georgiosd commented 4 years ago

On latest MacOS with dotnet core 3.1.5, a 3.1 project referencing RazorLight will fail with:

/Users/georgiosd/Documents/studoyo/api/xxxx.csproj : error NU1102: Unable to find package Microsoft.CodeAnalysis.CSharp with version (>= 3.3.0)
/Users/georgiosd/Documents/studoyo/api/xxxx.csproj : error NU1102:   - Found 62 version(s) in nuget.org [ Nearest version: 3.0.0 ]
/Users/georgiosd/Documents/studoyo/api/xxxx.csproj : error NU1102: Unable to find package Microsoft.CodeAnalysis.Common with version (>= 3.3.0)
/Users/georgiosd/Documents/studoyo/api/xxx.csproj : error NU1102:   - Found 62 version(s) in nuget.org [ Nearest version: 3.0.0 ]
    0 Warning(s)
    2 Error(s)

I tried downgrading all the way down to beta1 and it fails with a different error.

Any ideas?

georgiosd commented 4 years ago

Seems to be a problem with the package but if you know of any workarounds let me know! https://github.com/dotnet/roslyn/issues/45516

jzabroski commented 4 years ago

This may be a duplicate of #348 . In effect, we don't directly depend upon Microsoft.CodeAnalysis.CSharp or Microsoft.CodeAnalysis.Common. Instead, we depend upon Microsoft.CodeAnalysis.Razor. But, to be honest, debugging .NET link-load issues is complex because you have to travel all the way up the nuget stack to figure this stuff out.

image

georgiosd commented 4 years ago

@jzabroski yes, I noticed all that. But then I removed RazorLight and added the package in question (which on nuget.org appear to have 3.6.0+ versions) and the dotnet core still couldn't find it so I think it's an issue with nuget or the package itself.

jzabroski commented 4 years ago

@georgiosd It looks like nuget restore supports a Verbosity detailed flag. Can you:

  1. Output nuget.exe (no parameters) to dump the version info (I have 5.6.0.6591 on my work pc in Amazon Workspaces)
  2. Output nuget.exe restore -Verbosity detailed (ignore for a second that you should restore via dotnet.exe)
  3. Output dotnet.exe restore --verbosity detailed. It is possible dotnet.exe restore --verbosity diagnostic may provide even more info, though I don't know enough about Dotnet/Nuget internals to guess why dotnet.exe wouldn't just pass the same logging configuration through to nuget.exe underlying API.
  4. Follow https://docs.microsoft.com/en-us/nuget/consume-packages/package-restore-troubleshooting - this step is pretty much a prerequisite to getting an issue escalated with Visual Studio / Nuget teams, as they literally say in this web page to follow these steps before submitting an issue.
jzabroski commented 4 years ago

@georgiosd I think this issue might only happen on Mac, which is why I can't reproduce it. It may be a duplicate of #292

I guess, my question is, how can I repro a Mac issue? What's the best practice? I don't own mac any more. Mine fried two years ago and I went Lenovo/Windows 10 Pro due to WSL support letting me run Linux inside Windows. One way would be to move to GitHub Actions for CI/CD and use a Mac host runner type. https://devblogs.microsoft.com/dotnet/continuous-integration-workflow-template-for-net-core-desktop-apps-with-github-actions/ But I am curious as you also run your own software company, what your best practices are?

jzabroski commented 4 years ago

Googling for NU1102 mac os x

I found this: https://stackoverflow.com/questions/58074542/unable-to-find-package-microsoft-netcore-app-host-osx-x64-after-upgrading-to

georgiosd commented 4 years ago

Thanks for spending time on this @jzabroski !

We make mobile apps also, so while half our team owns a personal Mac, we found that it's often necessary to use an independent box and we have rented a dedicated mac mini for $99/mo. I think there was a cheaper option for $80/mo or so.

If it's something that can be solved with tests, you can definitely use a mac host - https://docs.microsoft.com/en-us/azure/devops/pipelines/agents/hosted?view=azure-devops&tabs=yaml

georgiosd commented 4 years ago

PS: I think it's unlikely to be the runtime because I only have 3.1.5 on my Mac right now, but I will check it

jzabroski commented 4 years ago

I think it's most likely the mac stuff wasn't packaged correctly by Microsoft (or the macos build stack is non-deterministic in some way). I run another project, FluentMigrator, where I ran into huge issues where System.ComponentModel.DataAnnotations wasnt packaged by EF team in a way that would allow you to write netstandard2.0 assemblies against a 4.7.2 executable. I notice that when packages are not maintained by the "in-box .NET" package set, they drift in packaging standards. It's probably something similar.

Getting a mac mini or similar, not a bad idea. I will check FB Marketplace for cheap refurb. Is there a minimum OS i should run?

georgiosd commented 4 years ago

@jzabroski yeah if you can keep it at home it's obviously going to be cheaper! We have to have it accessible from anywhere so the online dedi box made sense.

I dont know an awful lot about Mac OS versions but it seems that the earliest offered by MS is 10.14 - I wouldn't go any lower!

jzabroski commented 4 years ago

I should be able to get a Mac Mini on Sunday for $100 USD. So, realistically, ETA to fix this is at least two weeks out.

georgiosd commented 4 years ago

Really? That cheap!? Wow. If you're just getting it for this fix, I can probably offer a temp account on our remote machine.

jzabroski commented 4 years ago

Yeah man. FaceBook Marketplace. I dont know if they have it in Greece but it's pretty sweet way to deal in secondary markets. Sometimes you end up with crap but I'd say it's net saved me money. (I once bought a Dr. Beats metronome on there that after I took it home, realized it didn't actually work correctly.) This Mac Mini is 10.11 but I can use dosdude to upgrade to Mojave.

georgiosd commented 4 years ago

Very cool indeed! We certainly have it here but I don't use it very much because of quality concerns, but for that price, who can argue :)

Let me know what you find! I'm working from my laptop today so will have to uncomment RazorLight usages

On Wed, Jul 01, 2020 at 18:27:06, John Zabroski < notifications@github.com > wrote:

Yeah man. FaceBook Marketplace. I dont know if they have it in Greece but it's pretty sweet way to deal in secondary markets. Sometimes you end up with crap but I'd say it's net saved me money. (I once bought a Dr. Beats metronome on there that after I took it home, realized it didn't actually work correctly.) This Mac Mini is 10.11 but I can use dosdude to upgrade to Mojave.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub ( https://github.com/toddams/RazorLight/issues/350#issuecomment-652486373 ) , or unsubscribe ( https://github.com/notifications/unsubscribe-auth/AAMYG5TJB533L2ASU5EP5TLRZNIUVANCNFSM4OLHDUPQ ).

georgiosd commented 4 years ago

So when adding the Microsoft.CodeAnalysis.CSharp package I noticed it then complains about Microsoft.CodeAnalysis.Common package. Then I tried installing that instead and I think the last line is telling:

error: Package 'Microsoft.CodeAnalysis.Common' is incompatible with 'all' frameworks in project
georgiosd commented 4 years ago

Another interesting fact. Adding RazorLight 1.x works fine. Adding Microsoft.CodeAnalysis.Common on a fresh project adds 3.0.0. Then adding RazorLight 2.0 fails because it wants > 3.3.0 which cannot be found :S

jzabroski commented 4 years ago

Until I have a Mac I don't think I can figure out what MSBuild/Nuget is doing to cause you so much headaches.

georgiosd commented 4 years ago

I know, just adding context :)

jzabroski commented 4 years ago

A dumb idea, but can you try <RollForward>LatestFeature</RollForward> and see if that changes the outcome? It shouldn't, but hey...

georgiosd commented 4 years ago

Nope...

On Fri, Jul 03, 2020 at 17:52:32, John Zabroski < notifications@github.com > wrote:

A dumb idea, but can you try LatestFeature and see if that changes the outcome? It shouldn't, but hey...

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub ( https://github.com/toddams/RazorLight/issues/350#issuecomment-653583305 ) , or unsubscribe ( https://github.com/notifications/unsubscribe-auth/AAMYG5UIV64T4NBEZEAD6STRZXWDBANCNFSM4OLHDUPQ ).

jzabroski commented 4 years ago

@georgiosd I think this is actually related to #360

georgiosd commented 4 years ago

@jzabroski how could that be true? My project is ASP.NET Core already :S

georgiosd commented 3 years ago

Hey @jzabroski - what's the status of this? I'm getting a similar error on Windows now with RC2!

Unhandled exception. System.AggregateException: Some services are not able to be constructed (Error while validating the service descriptor 'ServiceType: RazorLight.IEngineHandler Lifetime: Singleton ImplementationType: RazorLight.EngineHandler': No constructor for type 'RazorLight.EngineHandler' can be instantiated using services from the service container and default values.)
 ---> System.InvalidOperationException: Error while validating the service descriptor 'ServiceType: RazorLight.IEngineHandler Lifetime: Singleton ImplementationType: RazorLight.EngineHandler': No constructor for type 'RazorLight.EngineHandler' can be instantiated using services from the service 
container and default values.
 ---> System.InvalidOperationException: No constructor for type 'RazorLight.EngineHandler' can be instantiated using services from the service container and default values.
jzabroski commented 3 years ago

This appears to be a different error than the one you previously reported.

Can you please check how you are registering RazorLight with your container?

georgiosd commented 3 years ago

You're right, I mixed up the issues. I solved this one by doing services.AddSingleton(Options.Create(engine.Options))

jzabroski commented 3 years ago

@georgiosd As a check - is this original issue now also resolved on MacOS? If yes, for what target frameworks did you confirm it now works. Thank you.

jzabroski commented 3 years ago

@georgiosd Just wondering if your original issue is resolved? It turns out github actions supports macos images for virtual environments!

https://github.com/actions/virtual-environments/tree/main/images/macos

georgiosd commented 3 years ago

Forgive me , I haven't checked yet, give me a few days! Happy new year!

On Mon, Jan 04, 2021 at 2:53 AM, John Zabroski < notifications@github.com > wrote:

@ georgiosd ( https://github.com/georgiosd ) Just wondering if your original issue is resolved? It turns out github actions supports macos images for virtual environments!

https:/ / github. com/ actions/ virtual-environments/ tree/ main/ images/ macos ( https://github.com/actions/virtual-environments/tree/main/images/macos )

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub ( https://github.com/toddams/RazorLight/issues/350#issuecomment-753706149 ) , or unsubscribe ( https://github.com/notifications/unsubscribe-auth/AAMYG5VAVGPZHYZK6VKLWLLSYEGSBANCNFSM4OLHDUPQ ).

jzabroski commented 3 years ago

@georgiosd I am going to close this now that I merged #407 which covers the build matrix for RazorLight #299

georgiosd commented 3 years ago

Well done! Happy new year.

On Tue, Jan 05, 2021 at 1:57 AM, John Zabroski < notifications@github.com > wrote:

Closed #350 ( https://github.com/toddams/RazorLight/issues/350 ).

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub ( https://github.com/toddams/RazorLight/issues/350#event-4167271928 ) , or unsubscribe ( https://github.com/notifications/unsubscribe-auth/AAMYG5SNN35IIJLJE3S4QMTSYJIX5ANCNFSM4OLHDUPQ ).