After upgrading to 1.0.0, I am unable to restore packages. I get the following error:
Version conflict detected for Microsoft.CodeAnalysis.CSharp.
DemoApp (>= 1.0.0) -> DemoApp.Library (>= 1.0.0) -> RazorLight (>= 1.0.0) -> Microsoft.CodeAnalysis.CSharp (>= 1.3.2)
DemoApp (>= 1.0.0) -> Microsoft.VisualStudio.Web.CodeGeneration.Design (>= 1.1.0) -> Microsoft.VisualStudio.Web.CodeGeneration.Utils (>= 1.1.0) -> Microsoft.CodeAnalysis.CSharp.Workspaces (>= 1.3.0) -> Microsoft.CodeAnalysis.CSharp (>= 1.3.0).
Downgrading to 1.0.0-rc2 resolves the issue.
Version conflict messages, usually are just warnings, not errors. Are you sure this is exactly a compilation error?
It isn't a compilation error. The nuget package restore fails.
I have a similar problem. I returned to version 1.0.0-RC2.
Hmm. strange. Investigating...
@KolyaNET & @ericwscott
Can you please share your .csproj file?
@toddams - I can't share the .csproj file I'm currently using. I'll see if I can put together a small test that I can share.
Any news @ericwscott ?
I was able to reproduce the problem by creating a new Visual Studio 2017 Asp.Net Core Web Application with Individual Account authentication. The zipped .csproj file is attached.
The conflict appears to be with:
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="1.1.0" PrivateAssets="All" />
I use project.json.
To fix the dependency conflicts, I added the following packages to my project:
"Microsoft.CodeAnalysis.Common": "1.3.2",
"Microsoft.CodeAnalysis.CSharp": "1.3.2",
"Microsoft.CodeAnalysis.CSharp.Workspaces": "1.3.2",
"Microsoft.CodeAnalysis.Workspaces.Common": "1.3.2",
Thanks @KolyaNET. I added these references to the .csproj file and the package restore is successful.
<PackageReference Include="Microsoft.CodeAnalysis.Common" Version="1.3.2" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="1.3.2" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="1.3.2" />
<PackageReference Include="Microsoft.CodeAnalysis.Workspaces.Common" Version="1.3.2" />
I will add this to FAQ, closing the issue
@KolyaNET @ericwscott I also have this error. Those references include a warning not to include them manually.
Do you believe this is a good long term solution? There might be a better way?
@grokky1 No, I do not believe that this is a good solution. But at the moment I do not know another way to solve this problem.
@KolyaNET Yeah me too. I feel this is a workaround, not a solution.
I could lower package version to 1.3.0, to avoid the version conflict with asp.net MVC, but who guarantees that one would not use other library/framework that may cause another conflict. This is definitely not a problem of RazorLight, but a nuget that can not deal with using the same package with different versions
Ok. Seems like this issue is more annoying that it may appear. Reopening again for further investigation.
@toddams I included the references and forgot about this. But then I saw that those packages have this warning:
Do not install this package manually, it will be added as a prerequisite by other packages that require it.
So there should be a way for multiple packages to depend on different versions of these dependent packages.
But I'm not sure why it doesn't do that automatically, because in my Visual Studio, under "References", it shows each referenced package, and underneath it which dependent packages it depends on. And there are multiple versions of the same package. So it should be possible.
@grokky1
I uploaded 1.1.0 version. Can you confirm that it resolves the issue?
install-package Razorlight -version 1.1.0
@toddams I'm not 100% sure because I'm using "RazorLight.MVC", not "RazorLight".
I removed the Microsoft.CodeAnalysis.* packages, then temporarily I added both:
"RazorLight": "1.1.0",
"RazorLight.MVC": "1.0.4",
Package restore works, and no more warnings or errors!
Updated to RazorLight 1.1.0, removed PackageReferences for Microsoft.CodeAnalysis.*.
Package restore completed successfully. Seems like a good solution to me.
@toddams @grokky1 I deleted the packages Microsoft.CodeAnalysis.* and updated RazorLight. Everything works well. Thank you.
@toddams Looks good... Could we please update RazorLight.MVC as well?
(so we don't need to reference both packages, just the mvc one)
Most helpful comment
I use project.json.
To fix the dependency conflicts, I added the following packages to my project: