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

The "nuget restore" command fails #21180

Closed
MaksimZhukov opened this issue Aug 4, 2021 · 22 comments
Closed

The "nuget restore" command fails #21180

MaksimZhukov opened this issue Aug 4, 2021 · 22 comments
Assignees

Comments

@MaksimZhukov
Copy link

The nuget restore command fails with new Mono version 6.12.0.140 and 6.12.0.147 on macOS 10.15 Catalina image with the following error:

/Users/runner/work/xamarin-forms-samples/xamarin-forms-samples/Todo/Todo.UWP/Todo.UWP.csproj : error MSB4057: The target "_IsProjectRestoreSupported" does not exist in the project.
/var/folders/24/8k48jl6d249_n_qfxwsl6xvm0000gn/T/NuGetScratch/qxkilfkb.j5z.nugetrestore.targets(315,5): warning : Skipping restore for project '/Users/runner/work/xamarin-forms-samples/xamarin-forms-samples/Todo/Todo.UWP/Todo.UWP.csproj'. The project file may be invalid or missing targets required for restore. [/var/folders/24/8k48jl6d249_n_qfxwsl6xvm0000gn/T/NuGetScratch/hczm5041.2wn.nugetinputs.targets]

Steps to Reproduce

We forked the xamarin/xamarin-forms-samples repository and created a workflow file to test mono with different applications. We specified the following mono versions for each app: 6.12.0.125 (default on hosted images), 6.12.0.140 and 6.12.0.147.

All builds with mono 6.12.0.125 are successful. Builds with other mono versions failed with the error that I mentioned above except 1 application. Please find details in the build logs.

Current Behavior

The nuget restore command fails

Expected Behavior

The nuget restore command passes successfully

On which platforms did you notice this

macOS

Version Used: 6.12.0.140 and 6.12.0.147

@MaximLipnin
Copy link
Contributor

I asked @MaksimZhukov to check whether NuGet.targets shipped with Mono 6.12.0.147 (/Library/Frameworks/Mono.framework/Versions/Current/lib/mono/msbuild/Current/bin/NuGet.targets) on Github-hosted runner contains the _IsProjectRestoreSupported target and according to Get content of the NuGet.targets build step it definitely does.
Another interesting observation here is that NuGet fails to restore only for *.UWP-projects.

@MaximLipnin
Copy link
Contributor

@rainersigwald sorry for bothering here - could you help identify any recent changes in MSBuild which could lead to such a problem? Perhaps, there is some gap between mono/msbuild and dotnet/msbuild but I wasn't able to track down the difference.
Was it unification of the restore process for any supported types of projects? It's interesting that *.Android or *.iOS projects can restore as usual on Mono 6.12.0.147 and *.UWP-projects are the only failing. On the earlier version of Mono (6.12.0.125) UWP-projects seemed to be skipped for restoring on macOS so that they didn't fail the whole build.

@rainersigwald
Copy link

I don't know of any recent changes that would result in something like this. Was there a nuget.exe change in that Mono version range, or only MSBuild?

@MaximLipnin
Copy link
Contributor

As far as I can see, there was a version bump for both NuGet and MSBuild - cc8b25a

@MaximLipnin
Copy link
Contributor

Maybe @radical, based on his experience, could point us out to the right direction? :)

@MaximLipnin
Copy link
Contributor

@mrward @KirillOsenkov in case you guys know anything about such a problem

@mrward
Copy link
Member

mrward commented Sep 2, 2021

Mono 6.12.0.147 has:

  • nuget 5.9.0.7134
  • MSBuild 16.10.1 (NuGet 5.9.1.8)

Does msbuild /t:restore work instead of using nuget restore?

@MaximLipnin
Copy link
Contributor

@MaksimZhukov Does this option work for you?

@nikolai-frolov
Copy link

Hello and thanks for your time. We investigated an issue deeper and found the issue root which was related to project.

Looking at the package restore logs for build with repro (https://github.com/nikolai-frolov/xamarin-forms-samples/actions/runs/1363166336), we found that both "nuget restore" and "msbuild /t:restore" for all Mono versions can't restore packages for Todo.UWP.csproj (due to project related issue) but difference is following:

  • "nuget restore" for Mono 6.12.0.125 throws neither warning nor error
  • "msbuild /t:restore" for all Mono versions throws warning
  • "nuget restore" for Mono 6.12.0.140+ throws a terminating error which fails our builds

In addition, I would like to pay your attention to odd Mono behavior which we found during investigation: "nuget restore" uses correct msbuild version (16+), but can't determine the version number correctly probably due to hardcoded 15.0 version (https://github.com/mono/mono/search?q=lib%2Fmono%2Fmsbuild%2F15.0&type=code).

nuget restore ./Todo/Todo.sln
MSBuild auto-detection: using msbuild version '15.0' from '/Library/Frameworks/Mono.framework/Versions/6.12.0/lib/mono/msbuild/15.0/bin'.
Restoring packages for /Users/runner/work/xamarin-forms-samples/xamarin-forms-samples/Todo/Todo/Todo.Android/Todo.Android.csproj...

@mrward
Copy link
Member

mrward commented Oct 25, 2021

The using msbuild version '15.0' message maybe a bit misleading since the /Library/Frameworks/Mono.framework/Versions/6.12.0/lib/mono/msbuild/15.0/ directory symlinks to the /Library/Frameworks/Mono.framework/Versions/6.12.0/lib/mono/msbuild/Current/ directory. Only one version of the MSBuild binaries are shipped with mono.

If you run mono /Library/Frameworks/Mono.framework/Versions/6.12.0/lib/mono/msbuild/15.0/bin/MSBuild.dll --version it should display an MSBuild 16.0 version.

@mgierlasinski
Copy link

@MaksimZhukov @MaximLipnin @nikolai-frolov @mrward

Any updates on this?

@nikolai-frolov
Copy link

@mgierlasinski I described above that it's not a Mono issue but a difference in how "nuget restore" in different mono versions deals with failure during package restoring. Our failure is related to project where we tried to restore packages.

@MaximLipnin
Copy link
Contributor

@nikolai-frolov thanks for diving into this! I'm just wondering if ignoring UWP-projects during restoring on MacOS works for you?

@mgierlasinski
Copy link

@nikolai-frolov This change of behaviour seems to have impact on AppCenter builds, suddenly they just started to fail because of Mono 6.12.* update. It seems that they need some scripted workaround.

@MaximLipnin
Copy link
Contributor

Removing UWP-projects is definitely a workaround here, e.g. jonathanpeppers/boots#87 (comment)

@nikolai-frolov
Copy link

@MaximLipnin Yes, we temporary disabled UWP subproject until it be fixed. Probably this issue can be resolved in case changing of "nuget restore" behavior is expected.
@mgierlasinski I don't own Mono, I only provided result of our internal investigation. If you have similar issue please make sure that you project restores all subprojects correctly, since for 6.12.0.140+ all ignored issues become a terminating alerts. As a workaround you can use "msbuild /t:restore" which throws warnings instead of errors.

@MaximLipnin
Copy link
Contributor

Probably this issue can be resolved in case changing of "nuget restore" behavior is expected.

Perhaps. something like

<PropertyGroup>
    <MSBuildWarningsAsMessages>$(MSBuildWarningsAsMessages);MSB4057</MSBuildWarningsAsMessages>
</PropertyGroup>

would help as well. However, there might be a problem as related code base doesn't seems to be in Mono's MSBuild fork but in some NuGet repo we're pulling in.

@MaksimZhukov
Copy link
Author

@MaximLipnin, do you know if there are plans to change this behavior in future versions of Mono, or will it remain the default?

@mgierlasinski
Copy link

@nikolai-frolov @MaximLipnin Thanks guys for explanation and help, removing UWP from solution in AppCenter script did the job, as described here:
jonathanpeppers/boots#87 (comment)

@MaximLipnin
Copy link
Contributor

@MaximLipnin, do you know if there are plans to change this behavior in future versions of Mono, or will it remain the default?

I wouldn't expect any changes in the behavior. One can remove UWP-projects from the solution and use msbuild /t:restore, which practically solves the problem, so we can close this issue.

@MaximLipnin
Copy link
Contributor

In total:

  • one may want to switch over to the latest official stable Mono 6.12.0.140
  • to avoid Xamarin forms solution restoring failure, remove UWP-project from the solution;
  • to make restoring not to fail build due to error, use msbuild /t:restore instead of nuget restore, it'll treat errors as warnings.

Since the workaround was successfully applied, I'm closing this issue. In case you guys have questions or need clarification on any Mono aspects, feel free to open another issue.

@skadookkunnan
Copy link

In total:

  • one may want to switch over to the latest official stable Mono 6.12.0.140
  • to avoid Xamarin forms solution restoring failure, remove UWP-project from the solution;
  • to make restoring not to fail build due to error, use msbuild /t:restore instead of nuget restore, it'll treat errors as warnings.

Since the workaround was successfully applied, I'm closing this issue. In case you guys have questions or need clarification on any Mono aspects, feel free to open another issue.

Yes. It works! Updated the pipeline.

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

No branches or pull requests

7 participants