.NET Core - Project version mismatch
Published on 03 Jun 2019
This problem usually happens when you’re working on a solution with multiple projects that were created using different versions of the .NET SDK.
The project was restored using Microsoft.NETCore.App version x.x.x, but with current settings, version y.y.y would be used instead
You may encounter this error when running dotnet build
or maybe only on dotnet publish
. In any case, the best way to get rid of this problem for good is the following:
- On the folder where your
.sln
file resides, create a new file namedDirectory.Build.props
. If you’re not working with a solution (not using Visual Studio), you can use create it on the root directory of your repository (usually where.gitignore
is; - With a text editor, add the following content to it:
<Project>
<PropertyGroup>
<TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>
<GenerateFullPaths>true</GenerateFullPaths>
<LangVersion>latest</LangVersion>
</PropertyGroup>
</Project>
What these properties do is make your projects always restore and compile using the latest version available.
Try running the command again. If all went right, it should be compiling successfully now!
In case it doesn’t work for you, you can add these lines manually on each of the
.csproj
files.
I hope that helps you, thanks for reading!
Read More
How to fix your Favicons
Favicons kinda suck. They should be a simple icon that identifies your webpage on a bunch of scenarios, i.e. the...
Click to read more…Spicing Up your GitHub Profile with HTML and CSS
Last year, GitHub added a new cool feature for the user profile. You can now add a README file to...
Click to read more…