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

upgrade to .net core sdk 3, fix docker/travis/win build #3

Merged
merged 15 commits into from
Dec 2, 2019

Conversation

enricosada
Copy link

@enricosada enricosada commented Dec 2, 2019

The travis build fails, i get the same error locally

dotnet pack -c Release -o /app/artifacts -p:Version=`cat /app/tools/version` src/NoSln
Microsoft (R) Build Engine version 16.0.450+ga8dc7f1d34 for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.
/app/src/NoSln/NoSln.Library.fsproj : error NU1403: The package NETStandard.Library.2.0.3 sha512 validation failed. The package is different than the last restore.
  Restore failed in 801.46 ms for /app/src/NoSln/NoSln.Library.fsproj.

I first tried (my first commits in this PR) to fix it with the workaround in NuGet/Home#7921 (comment) but no luck

I then upgraded to .net core sdk 3.0.100 who initially fixed the error.

The upgrade the base image in the dockerfile required to:

but i am back to initial issue, the example projects seems to have issues with lock, the dotnet pack was ok, but the next dotnet test was not

/usr/share/dotnet/sdk/3.0.100/NuGet.targets(123,5): error NU1004: The packages lock file is inconsistent with the project dependencies so restore can't be run in locked mode. Disable the RestoreLockedMode MSBuild property or pass an explicit --force-evaluate option to run restore to update the lock file. [/app/nosln.sln]

so i changed the build script to restore once with dotnet restore --locked-mode, and do not restore (--no-restore) in pack/test

Not the best, but seems to work both locally, on docker and travis

fix if .net core runtime 2.x is not installed

Scenario is dotnet nosln installed as global/local tool with .NET Core Sdk 3.x or in a docker container based on .NET Core Sdk 3.x

By default the tool expect an installed .NET Core Runtime >= 2.1 and < 3
The .NET Core Sdk 3.x doesnt contains the runtime 2.1.x, so fails at runtime with

It was not possible to find any compatible framework version
The specified framework 'Microsoft.NETCore.App', version '2.1.0' was not found.
  - The following frameworks were found:
      3.0.0 at [/usr/share/dotnet/shared/Microsoft.NETCore.App]

Because sdk and runtimes can be installed side by side, doesnt happen if the developer has a .net core sdk 2.1/2.2 installed (who bundle the 2.x runtime)

The issue can be repro'ed with the following dockerfile

FROM mcr.microsoft.com/dotnet/core/sdk:3.0.100
WORKDIR /app

RUN dotnet new tool-manifest

RUN dotnet tool install --local dotnet-nosln --version 0.6.1 

RUN dotnet nosln --version

This fix allow to run with any .net core runtime >= 2.1 so is compatible with any .NET Core Sdk >= 2.1

To make it work in both .net core sdk 2.x and 3.x i used "rollForwardOnNoCandidateFx": 2 in src/NoSln.Tool/runtimeconfig.template.json.

I tried add also the new fsproj property <RollForward>Major</RollForward> to be future proof, but the pack give and error if both are present (also if values are compatibile :( )

It's invalid to use both `rollForward` and one of `rollForwardOnNoCandidateFx` or `applyPatches` in the same runtime config.
Invalid runtimeconfig.json [/app/tools/.store/dotnet-nosln/0.6.2-alpha.0.5/dotnet-nosln/0.6.2-alpha.0.5/tools/netcoreapp2.1/any/dotnet-nosln.runtimeconfig.json] [/app/tools/.store/dotnet-nosln/0.6.2-alpha.0.5/dotnet-nosln/0.6.2-alpha.0.5/tools/netcoreapp2.1/any/dotnet-nosln.runtimeconfig.dev.json]

so i left the old one (supported in both sdks)

Enrico Sada added 8 commits December 2, 2019 17:31
```
dotnet nuget locals all --clear
git clean -xfd
git rm **/packages.lock.json -f
dotnet restore
```
bump to v2 to be runnable without .net core runtime 2.1
by default the tools expect an installed .net core NET Core Runtime >= 2.1 and < 3
The .NET Core Sdk 3.x doesnt contains the runtime 2.1.x, so fails at runtime with

```
It was not possible to find any compatible framework version
The specified framework 'Microsoft.NETCore.App', version '2.1.0' was not found.
  - The following frameworks were found:
      3.0.0 at [/usr/share/dotnet/shared/Microsoft.NETCore.App]
```

This fix allow to run with any .net core >= 2.1
Scenario is `dotnet nosln` installed as local tool in .net core sdk 3.x or in a docker container based on .net core sdk 3.x
@enricosada
Copy link
Author

@eiriktsarpalis you can repro this locally?

@enricosada enricosada changed the title check ci upgrade to .net core sdk 3, fix docker/travis/win build Dec 2, 2019
Copy link
Owner

@eiriktsarpalis eiriktsarpalis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this!

global.json Outdated
@@ -0,0 +1,5 @@
{
"sdk": {
"version": "3.0.100"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not a big fan of global.json files as they are too constraining on the dev environment. Generally prefer docker as a means to enforce reproducible builds.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed it

@enricosada
Copy link
Author

@eiriktsarpalis i had to add some workaround to fix the issue (i dont know nuget lock files quirks a lot), but now seems ok.

It fix also #2 so i'll close it

@eiriktsarpalis eiriktsarpalis merged commit 76c3251 into eiriktsarpalis:master Dec 2, 2019
@eiriktsarpalis
Copy link
Owner

Thanks!

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