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

"dotnet restore" doesn't work when project dependencies are manually specified #5193

Closed
Daniel15 opened this issue May 9, 2017 · 4 comments
Labels
Resolution:Duplicate This issue appears to be a Duplicate of another issue

Comments

@Daniel15
Copy link

Daniel15 commented May 9, 2017

Details about Problem

Visual Studio has a "project dependencies" feature that lets you manually specify dependencies between projects in a solution:

In one of my open-source projects, I was using this as part of a hack with the old tooling to reference an xproj project from a csproj. That hack is no longer needed, but I forgot about it until I encountered a strange problem:

dotnet restore does not restore the NuGet packages for any projects that use this feature.

See the test case here: NuGetRestoreBug.zip

I have two solution files:
good.sln does not use the project dependencies feature:


Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26228.4
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "A", "A\A.csproj", "{56B54AB3-3FBE-45D6-A15E-8B8678121B39}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "B", "B\B.csproj", "{7D13BEEC-5FCB-4145-9A74-64D859A6D70C}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "C", "C\C.csproj", "{4395093E-5ACA-4736-A8FD-55901807D37F}"
EndProject
Global
	GlobalSection(SolutionConfigurationPlatforms) = preSolution
		Debug|Any CPU = Debug|Any CPU
		Release|Any CPU = Release|Any CPU
	EndGlobalSection
	GlobalSection(ProjectConfigurationPlatforms) = postSolution
		{56B54AB3-3FBE-45D6-A15E-8B8678121B39}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
		{56B54AB3-3FBE-45D6-A15E-8B8678121B39}.Debug|Any CPU.Build.0 = Debug|Any CPU
		{56B54AB3-3FBE-45D6-A15E-8B8678121B39}.Release|Any CPU.ActiveCfg = Release|Any CPU
		{56B54AB3-3FBE-45D6-A15E-8B8678121B39}.Release|Any CPU.Build.0 = Release|Any CPU
		{7D13BEEC-5FCB-4145-9A74-64D859A6D70C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
		{7D13BEEC-5FCB-4145-9A74-64D859A6D70C}.Debug|Any CPU.Build.0 = Debug|Any CPU
		{7D13BEEC-5FCB-4145-9A74-64D859A6D70C}.Release|Any CPU.ActiveCfg = Release|Any CPU
		{7D13BEEC-5FCB-4145-9A74-64D859A6D70C}.Release|Any CPU.Build.0 = Release|Any CPU
		{4395093E-5ACA-4736-A8FD-55901807D37F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
		{4395093E-5ACA-4736-A8FD-55901807D37F}.Debug|Any CPU.Build.0 = Debug|Any CPU
		{4395093E-5ACA-4736-A8FD-55901807D37F}.Release|Any CPU.ActiveCfg = Release|Any CPU
		{4395093E-5ACA-4736-A8FD-55901807D37F}.Release|Any CPU.Build.0 = Release|Any CPU
	EndGlobalSection
	GlobalSection(SolutionProperties) = preSolution
		HideSolutionNode = FALSE
	EndGlobalSection
EndGlobal

bad.sln does use it - A depends on B, which depends on C:

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26228.4
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "A", "A\A.csproj", "{56B54AB3-3FBE-45D6-A15E-8B8678121B39}"
	ProjectSection(ProjectDependencies) = postProject
		{7D13BEEC-5FCB-4145-9A74-64D859A6D70C} = {7D13BEEC-5FCB-4145-9A74-64D859A6D70C}
	EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "B", "B\B.csproj", "{7D13BEEC-5FCB-4145-9A74-64D859A6D70C}"
	ProjectSection(ProjectDependencies) = postProject
		{4395093E-5ACA-4736-A8FD-55901807D37F} = {4395093E-5ACA-4736-A8FD-55901807D37F}
	EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "C", "C\C.csproj", "{4395093E-5ACA-4736-A8FD-55901807D37F}"
EndProject
Global
	GlobalSection(SolutionConfigurationPlatforms) = preSolution
		Debug|Any CPU = Debug|Any CPU
		Release|Any CPU = Release|Any CPU
	EndGlobalSection
	GlobalSection(ProjectConfigurationPlatforms) = postSolution
		{56B54AB3-3FBE-45D6-A15E-8B8678121B39}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
		{56B54AB3-3FBE-45D6-A15E-8B8678121B39}.Debug|Any CPU.Build.0 = Debug|Any CPU
		{56B54AB3-3FBE-45D6-A15E-8B8678121B39}.Release|Any CPU.ActiveCfg = Release|Any CPU
		{56B54AB3-3FBE-45D6-A15E-8B8678121B39}.Release|Any CPU.Build.0 = Release|Any CPU
		{7D13BEEC-5FCB-4145-9A74-64D859A6D70C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
		{7D13BEEC-5FCB-4145-9A74-64D859A6D70C}.Debug|Any CPU.Build.0 = Debug|Any CPU
		{7D13BEEC-5FCB-4145-9A74-64D859A6D70C}.Release|Any CPU.ActiveCfg = Release|Any CPU
		{7D13BEEC-5FCB-4145-9A74-64D859A6D70C}.Release|Any CPU.Build.0 = Release|Any CPU
		{4395093E-5ACA-4736-A8FD-55901807D37F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
		{4395093E-5ACA-4736-A8FD-55901807D37F}.Debug|Any CPU.Build.0 = Debug|Any CPU
		{4395093E-5ACA-4736-A8FD-55901807D37F}.Release|Any CPU.ActiveCfg = Release|Any CPU
		{4395093E-5ACA-4736-A8FD-55901807D37F}.Release|Any CPU.Build.0 = Release|Any CPU
	EndGlobalSection
	GlobalSection(SolutionProperties) = preSolution
		HideSolutionNode = FALSE
	EndGlobalSection
EndGlobal

dotnet restore good.sln shows what you'd expect:

λ dotnet restore good.sln
  Restoring packages for C:\temp\NuGetRestoreBug\A\A.csproj...
  Restoring packages for C:\temp\NuGetRestoreBug\B\B.csproj...
  Restoring packages for C:\temp\NuGetRestoreBug\C\C.csproj...
......

However, dotnet restore bad.sln only restores packages for C:

λ dotnet restore bad.sln
  Restoring packages for C:\temp\NuGetRestoreBug\C\C.csproj...
  Lock file has not changed. Skipping lock file write. Path: C:\temp\NuGetRestoreBug\C\obj\project.assets.json

NuGet product used: dotnet restore

dotnet.exe --version: 1.0.0

VS version: VS2017

OS version: Windows 10 10.0.16188.1000

@emgarten
Copy link
Member

emgarten commented May 9, 2017

Thanks for the report @Daniel15, this will be fixed in CLI 2.0.0 and VS 15.3

Dupe of #4578

@Daniel15
Copy link
Author

Daniel15 commented May 9, 2017

Haha, thanks. I didn't find that issue when searching. I guess I didn't need to spend all this time building a standalone repro 😛

@emgarten
Copy link
Member

emgarten commented May 9, 2017

I always appreciate a standalone repro! 😄

@mishra14
Copy link
Contributor

mishra14 commented May 9, 2017

Closed as dupe

@mishra14 mishra14 closed this as completed May 9, 2017
@mishra14 mishra14 added the Resolution:Duplicate This issue appears to be a Duplicate of another issue label May 9, 2017
Daniel15 added a commit to reactjs/React.NET that referenced this issue May 11, 2017
* Upgrade to Visual Studio 2017 + csproj tooling

* Include workaround for NuGet/Home#4337 (explicitly specify version when restoring NuGet packages)

* Work around dotnet/cli-migrate#11

* Upgrade to .NET Core 1.1.x

* Remove VersionPrefix from all csproj files

* Legacy NuGet restore is no longer needed

* Disable CS1701 warning for sample projects

* Turns out we actually do need the legacy NuGet restore

* Use VS2017 AppVeyor image

* Remove project dependencies to work around NuGet/Home#5193 and NuGet/Home#4578

* Use MSBuild 15 on AppVeyor

* Enforce .NET Core tools 1.0.0 in global.json

* Use newer npm on AppVeyor (as a workaround for https://github.com/dotnet/cli/issues/6561 and dotnet/msbuild#406), and run correct test command
toptaldev92 pushed a commit to toptaldev92/React.NET that referenced this issue Jul 28, 2021
* Upgrade to Visual Studio 2017 + csproj tooling

* Include workaround for NuGet/Home#4337 (explicitly specify version when restoring NuGet packages)

* Work around dotnet/cli-migrate#11

* Upgrade to .NET Core 1.1.x

* Remove VersionPrefix from all csproj files

* Legacy NuGet restore is no longer needed

* Disable CS1701 warning for sample projects

* Turns out we actually do need the legacy NuGet restore

* Use VS2017 AppVeyor image

* Remove project dependencies to work around NuGet/Home#5193 and NuGet/Home#4578

* Use MSBuild 15 on AppVeyor

* Enforce .NET Core tools 1.0.0 in global.json

* Use newer npm on AppVeyor (as a workaround for https://github.com/dotnet/cli/issues/6561 and dotnet/msbuild#406), and run correct test command
onlinehub0808 added a commit to onlinehub0808/React.NET that referenced this issue Jun 2, 2023
* Upgrade to Visual Studio 2017 + csproj tooling

* Include workaround for NuGet/Home#4337 (explicitly specify version when restoring NuGet packages)

* Work around dotnet/cli-migrate#11

* Upgrade to .NET Core 1.1.x

* Remove VersionPrefix from all csproj files

* Legacy NuGet restore is no longer needed

* Disable CS1701 warning for sample projects

* Turns out we actually do need the legacy NuGet restore

* Use VS2017 AppVeyor image

* Remove project dependencies to work around NuGet/Home#5193 and NuGet/Home#4578

* Use MSBuild 15 on AppVeyor

* Enforce .NET Core tools 1.0.0 in global.json

* Use newer npm on AppVeyor (as a workaround for https://github.com/dotnet/cli/issues/6561 and dotnet/msbuild#406), and run correct test command
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Resolution:Duplicate This issue appears to be a Duplicate of another issue
Projects
None yet
Development

No branches or pull requests

3 participants