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

Nuget restore macOS14-15 #11464

Open
3 of 16 tasks
Pmr-precure opened this issue Jan 24, 2025 · 10 comments
Open
3 of 16 tasks

Nuget restore macOS14-15 #11464

Pmr-precure opened this issue Jan 24, 2025 · 10 comments

Comments

@Pmr-precure
Copy link

Description

No idea if this is a bug or just me being stupid. Im trying to add a Private nuget package to my MAUI project. But when adding it with NugetCommand and trying to restore it. it gives following error:

error MSB4185: The function "Now" on type "System.DateTimeOffset" is not available for execution as an MSBuild property function.

I use the DatetimeOffset to set the build version. And it has never been an issue before, only now when i try to "restore".

I see when its running the nuget restore command it autodetects MSBuild version 15, that might be the issue? Not sure.

  • task: NuGetToolInstaller@1
    inputs:
    versionSpec:
    checkLatest: true
    • task: NuGetCommand@2
      inputs:
      command: 'restore'
      restoreSolution: '**/*.sln'
      feedsToUse: 'select'
      vstsFeed: '72c0baca-4087-8-1c4611d2717c'

Platforms affected

  • Azure DevOps
  • GitHub Actions - Standard Runners
  • GitHub Actions - Larger Runners

Runner images affected

  • Ubuntu 20.04
  • Ubuntu 22.04
  • Ubuntu 24.04
  • macOS 12
  • macOS 13
  • macOS 13 Arm64
  • macOS 14
  • macOS 14 Arm64
  • macOS 15
  • macOS 15 Arm64
  • Windows Server 2019
  • Windows Server 2022
  • Windows Server 2025

Image version and build link

20250106.587

Is it regression?

No

Expected behavior

Not failing to restore.

Actual behavior

Throws error.

Repro steps

Run nuget restore

@susmitamane
Copy link
Contributor

Hi @Pmr-precure

We will investigate the issue and keep you posted on further updates.

Thank you.

@Pmr-precure
Copy link
Author

Hi @Pmr-precure

We will investigate the issue and keep you posted on further updates.

Thank you.

Thank you, it works just fine on windows-2022 when building our Android app.
Here i also see it uses "MSBuild auto-detection: using msbuild version '17.12.12.57101'" and not 15.

BR.

@Pmr-precure
Copy link
Author

Any news on this? Right now its preventing us from deploying our iOS app.

BR.

@susmitamane
Copy link
Contributor

@Pmr-precure I understand your concern. We're still looking into this—please allow us some more time, and we'll get back to you with updates.

@susmitamane
Copy link
Contributor

Hi @Pmr-precure

  • I tired checking this from my end as the repro steps are not much clear didnt get much inputs below are the finding on the basis of initial analysis.
  1. MSBuild allows property functions (like System.DateTimeOffset.Now) but restricts them during NuGet restore due to security concerns. This restriction is more common on macOS/Linux agents compared to Windows.

  2. Could you please try :

<PropertyGroup>
    <BuildVersion>$([System.DateTimeOffset]::UtcNow.ToString("yyyyMMdd.HHmmss"))</BuildVersion>
</PropertyGroup>

  1. Since restore doesn’t need a timestamp, you should set the build version during the build step, not during restore.
<PropertyGroup Condition="'$(Restore)' != 'true'">
    <BuildVersion>$([System.DateTimeOffset]::Now.ToString("yyyyMMdd.HHmmss"))</BuildVersion>
</PropertyGroup>

  • To do further analysis could you please provide more reproducing steps so that i can understand the issue and check or may be you can provide workflow which you are using if it is not private.

@Pmr-precure
Copy link
Author

Pmr-precure commented Jan 30, 2025

Hi @Pmr-precure

* I tired checking this from my end as the repro steps are not much clear didnt get much inputs below are the finding on the basis of initial analysis.


1. MSBuild allows property functions (like System.DateTimeOffset.Now) but restricts them during NuGet restore due to security concerns. This restriction is more common on macOS/Linux agents compared to Windows.

2. Could you please try :
<PropertyGroup>
    <BuildVersion>$([System.DateTimeOffset]::UtcNow.ToString("yyyyMMdd.HHmmss"))</BuildVersion>
</PropertyGroup>
3. Since restore doesn’t need a timestamp, you should set the build version during the build step, not during restore.
<PropertyGroup Condition="'$(Restore)' != 'true'">
    <BuildVersion>$([System.DateTimeOffset]::Now.ToString("yyyyMMdd.HHmmss"))</BuildVersion>
</PropertyGroup>
* To do further analysis could you please provide more reproducing steps so that i can understand the issue and check or may be you can provide workflow which you are using if it is not private.

Hi,

I tried with the conditional, but it seems to just skip that in the process, throwing the same error.

##[error]The nuget command failed with exit code(1) and error(/Users/runner/work/1/s/MLI_App/MLI_App.csproj(20,3): error MSB4185: The function "UtcNow" on type "System.DateTimeOffset" is not available for execution as an MSBuild property function.

Image

This is how i have it, and it has never been an issue before. Only now when we have to use a private nuget package. and needs to do the restore step.

BR

@Pmr-precure
Copy link
Author

But why is it that the macOS uses version 15? and not 17.X as windows?

Image

@Pmr-precure
Copy link
Author

I tried to remove the Datetime, and just put "123",

And it still throws an error, now this:

##[error]The nuget command failed with exit code(1) and error(/var/folders/ps/c0906c6x6pnghyl4jw54srz00000gn/T/NuGetScratchrunner/j9iljr3h.48u.nugetrestore.targets(206,5): error MSB4018: The "WriteRestoreGraphTask" task failed unexpectedly. [/var/folders/ps/c0906c6x6pnghyl4jw54srz00000gn/T/NuGetScratchrunner/uunbtdyt.bq2.nugetinputs.targets]

@susmitamane
Copy link
Contributor

I tried to remove the Datetime, and just put "123",

And it still throws an error, now this:

##[error]The nuget command failed with exit code(1) and error(/var/folders/ps/c0906c6x6pnghyl4jw54srz00000gn/T/NuGetScratchrunner/j9iljr3h.48u.nugetrestore.targets(206,5): error MSB4018: The "WriteRestoreGraphTask" task failed unexpectedly. [/var/folders/ps/c0906c6x6pnghyl4jw54srz00000gn/T/NuGetScratchrunner/uunbtdyt.bq2.nugetinputs.targets]

  • The error indicates that the nuget restore command failed during the restore process due to an issue with the WriteRestoreGraphTask task. The error message, specifically MSB4018, is task failed unexpectedly, possibly due to a misconfiguration or environmental issue.
  • Let me check more on this and your questions and get back to you. As asked earlier if possible please try to provide proper repro steps and the workflows if the repos are not private.

@Pmr-precure
Copy link
Author

I tried to remove the Datetime, and just put "123",
And it still throws an error, now this:
##[error]The nuget command failed with exit code(1) and error(/var/folders/ps/c0906c6x6pnghyl4jw54srz00000gn/T/NuGetScratchrunner/j9iljr3h.48u.nugetrestore.targets(206,5): error MSB4018: The "WriteRestoreGraphTask" task failed unexpectedly. [/var/folders/ps/c0906c6x6pnghyl4jw54srz00000gn/T/NuGetScratchrunner/uunbtdyt.bq2.nugetinputs.targets]

* The error indicates that the nuget restore command failed during the restore process due to an issue with the WriteRestoreGraphTask task. The **error message, specifically MSB4018,  is task failed unexpectedly, possibly due to a misconfiguration or environmental issue.**

* **Let me check more on this and your questions and get back to you**. As asked earlier if possible please try to provide proper repro steps and the workflows if the repos are not private.

The project is private.

But creating a MAUI project -> add a private nuget package in azure artifacts -> restore it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants