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

Issue with Package source mapping by adding prefix feed. When executing dotnet restore facing issue, where it is inputting 5times feed as prefix #12328

Closed
crsreddy1447 opened this issue Dec 19, 2022 · 12 comments
Labels

Comments

@crsreddy1447
Copy link

crsreddy1447 commented Dec 19, 2022

Issue with Package source mapping by adding prefix feed. When executing dotnet restore facing issue, where it is inputting 5times feed as prefix
error NU1100: Unable to resolve 'Intergraph.TestTools.Clipper.UnitTesting (>= 1.0.8)' for 'net6.0'. PackageSourceMapping is enabled, the following source(s) were not considered: feed-feed-hexagonppmclipper, feed-feed-hexagonppmclipperfeaturebranch, feed-feed-SDXInternal, nuget.org, PPM. [/agent/_work/1/s/SPF/Services/xxxxxxxxxxxxxxxxxxx.netcore.csproj

Common.netstandard (>= 1.0.37)' for 'net6.0'. PackageSourceMapping is enabled, the following source(s) were not considered: feed-feed-feed-feed-feed-hxxxxxxxper, feed-feed-feed-feed-feed-hxxxxxrfeaturebranch, feed-feed-feed-feed-feed-SxxInternal, nuget.org, PPM.

these kind of error I am facing. I am using Dotnet restore in Linux Azure virtual machine scale set pool as agent machine.

          - task: DotNetCoreCLI@2
            displayName: "dotnet restore"
            retryCountOnTaskFailure: 3
            inputs:
              command: restore
              projects: "$(assemblyPath)"
              feedsToUse: config
              nugetConfigPath: NuGet.Config

Declared feeds in this way as per this link #11406

		<packageSource key="feed-PPM">
			<package pattern="webapi.nuget" />
		</packageSource>
		<packageSource key="PPM">
			<package pattern="webapi.nuget" />
		</packageSource>

Please help me how to resolve this issue

@ghost
Copy link

ghost commented Dec 19, 2022

Issue is missing Type label, remember to add a Type label

@ghost ghost added the missing-required-type The required type label is missing. label Dec 19, 2022
@crsreddy1447 crsreddy1447 reopened this Dec 19, 2022
@ghost
Copy link

ghost commented Dec 19, 2022

Issue is missing Type label, remember to add a Type label

@ghost ghost removed the missing-required-type The required type label is missing. label Dec 19, 2022
@erdembayar erdembayar added Functionality:SDK The NuGet client packages published to nuget.org Functionality:Restore Area:PackageSourceMapping Issues related to the package source mapping feature Product:dotnet.exe and removed Functionality:SDK The NuGet client packages published to nuget.org labels Dec 19, 2022
@erdembayar
Copy link
Contributor

erdembayar commented Dec 19, 2022

Thank you for filing this issue. If I understand correctly are refering this bold hightlighted part feed-feed-feed-feed-feed-hxxxxxrfeaturebranch as problem?
Are you using GithubAction or Azure CI pipeline? Could you please share simple repro code with you CI pipeline yml so I can reproduce it?

@crsreddy1447
Copy link
Author

Using Azure CI yaml pipeline. In pipipeline approx 5 dotnet restore task there. Remaining four works fine except this task
main file is build-fb.yml
template is jobs-L1L2Test.yml getting error in this template line 137.
nuget.config file
jobs-L1L2Test.zip

check agent pool is Linux scaleset. Remaining all restore are working fine

@zivkan
Copy link
Member

zivkan commented Dec 20, 2022

@crsreddy1447 Please avoid using the NuGetCommand or DotnetCliCommand tasks in Azure DevOps. We reported to them a year ago that their design breaks package source mapping: microsoft/azure-pipelines-tasks#15542

They said they're looking to deprecate these commands and recommend customers use script tasks to invole msbuild, nuget.exe, or dotnet directly, and use the NuGetAuthenticate task to set up credentials for private feeds. Another customer gave a simple to understand example: microsoft/azure-pipelines-tasks#15542 (comment)

@crsreddy1447
Copy link
Author

But the ticket microsoft/azure-pipelines-tasks#15542 (comment) is still in open. So we used this method by using feed as prefix. We have many dependencies on this. If we change to intead of dotnet restore lot many changes we have to do. Also in dotnet core cli we can use wildcard way ie(**/*.netcore.csproj) but in powershell we cannot use. Any way to use that?

@erdembayar erdembayar added the WaitingForClientTeam Customer replied, needs attention from client team. Do not apply this label manually. label Dec 20, 2022
@erdembayar
Copy link
Contributor

erdembayar commented Dec 20, 2022

Also in dotnet core cli we can use wildcard way ie(**/*.netcore.csproj) but in powershell we cannot use. Any way to use that?

Could you just iterate through all *.csproj in powershell to restore one by one? Even though microsoft/azure-pipelines-tasks#15542 (comment) is just single line of powershell command, you can do multiple lines of advanced powershell commands in 1 task.

@ghost ghost added WaitingForCustomer Applied when a NuGet triage person needs more info from the OP and removed WaitingForClientTeam Customer replied, needs attention from client team. Do not apply this label manually. labels Dec 20, 2022
@crsreddy1447
Copy link
Author

I am getting error MSBUILD : error MSB1009: Project file does not exist.
Switch: *.csproj
Command used is
dotnet restore *.csproj --configfile .\nuget.config --verbosity Detailed

Finally issue resolved my removing dotNet restore task which was failing

@ghost ghost added WaitingForClientTeam Customer replied, needs attention from client team. Do not apply this label manually. and removed WaitingForCustomer Applied when a NuGet triage person needs more info from the OP labels Dec 21, 2022
@zivkan
Copy link
Member

zivkan commented Dec 21, 2022

Can you create a solution file, and add all your projects to that solution, so no file globbing is needed in the dotnet restore my.sln command line? It's a one time effort of dotnet new sln ; dotnet sln add path\to\project.csproj. The dotnet sln add can be scripted, so it doesn't need to be done manually. I'm not familiar with bash, but gci -recuse -filter *.csproj | foreach-object { & dotnet sln add $_.FullName } might work in PowerShell.

But the ticket microsoft/azure-pipelines-tasks#15542 (comment) is still in open

For better or worse, the NuGet team does not own or maintain the Azure DevOps tasks. Feel free to upvote (add a 👍 reaction) to the issue, or comment on it, but we don't have permissions to change their code. At best we can create a pull request, but that requires us to understand how it works, and re-implement their private feed permissions in a different way. Otherwise, we need to wait until they deem the issue important enough to prioritize and schedule in a sprint.

@erdembayar erdembayar added WaitingForCustomer Applied when a NuGet triage person needs more info from the OP and removed WaitingForClientTeam Customer replied, needs attention from client team. Do not apply this label manually. labels Dec 21, 2022
@ghost ghost added the Status:No recent activity No recent activity. label Jan 5, 2023
@ghost
Copy link

ghost commented Jan 5, 2023

This issue has been automatically marked as stale because we have not received a response in 14 days. It will be closed if no further activity occurs within another 14 days of this comment.

@crsreddy1447
Copy link
Author

Issue was resolved
***For single file
dotnet restore 'Test.UnitTests.csproj' --configfile NuGet.Config
***** For Wildcard
dir "
/
.netcore.csproj" -Recurse | %{dotnet restore $PSItem.FullName --configfile NuGet.Config}

we followed prefix method. Due to some internal props file we faced the issue. Now it was resolved. Thanks for all the responses

@ghost ghost removed the WaitingForCustomer Applied when a NuGet triage person needs more info from the OP label Jan 9, 2023
@zivkan
Copy link
Member

zivkan commented Jan 9, 2023

note that NuGet is more efficient when it runs on a solution, so it can restore projects in parallel, and cache package information in-memory, rather than running once per project. Another problem with the "run restore once per project file" approach is that NuGet will automatically restore referenced projects, meaning that every ProjectReference will cause multiple restores. The second and subsequent restore of a project will be fast, a "no-op" restore, but not needing to check for a no-op restore is faster than a doing a no-op restore.

I suggest creating a solution file and restoring that solution.

joelverhagen added a commit to NuGet/Insights that referenced this issue Sep 13, 2023
syedrizvinet added a commit to syedrizvinet/Insights-scripts-test that referenced this issue Apr 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants