Skip to content
This repository has been archived by the owner on Oct 2, 2019. It is now read-only.

NuProj auto-detection of packages folder is not always working #300

Open
ivan-sam opened this issue Apr 30, 2018 · 0 comments
Open

NuProj auto-detection of packages folder is not always working #300

ivan-sam opened this issue Apr 30, 2018 · 0 comments

Comments

@ivan-sam
Copy link

ivan-sam commented Apr 30, 2018

NuProj ReadPackagesConfig task tries to locate package directory path (PackageReferences.PackageDirectoryPath metadata) by probing directories <currentDir>\packages\<package-id>.<package-version> starting from project's directory all the way up.

Later PackageDirectoryPath is used to exclude libraries coming from NuGet dependencies from final package files list (target GetPackageFiles).

I found NuGet dependency library in output package's lib folder while migration NuGet projects from using NuBuild to NuProj. Investigation showed that layout of solution caused the problem: solution file is located in it's own subfolder. packages folder by convention is located near the solution file.

│   
├───NuGetPackage1
│       packages.config
│       Readme.txt
│       TestProjNuGet.nuproj
│       
├───solutions
│   │   NuProjTest.sln
│   │   
│   └───packages
│       ├───Newtonsoft.Json.11.0.2
│       │   │   LICENSE.md
│       │   │   Newtonsoft.Json.11.0.2.nupkg
│       │   │   
│       │   └───lib
│       │               
│       │               
│       ├───NuProj.0.20.9-beta
│       │   │   NuProj.0.20.9-beta.nupkg
│       │   │   
│       │   ├───build
│       │   │       NuProj.props
│       │   │       
│       │   └───tools
│       │       │   
│       │       └───Rules
│       │               
│       │               
│       └───NuProj.Common.0.20.9-beta
│           │   NuProj.Common.0.20.9-beta.nupkg
│           │   
│           └───build
│               │   NuProj.Common.targets
│               │   
│               ├───dotnet
│               │       NuProj.Common.targets
│               │       
│               └───portable-net+win+wpa+wp+sl+netmf+MonoAndroid+MonoTouch+Xamarin.iOS
│                       NuProj.Common.targets
│                       
├───TestProj
│   │   Class1.cs
│   │   packages.config
│   │   TestProj.csproj
│   │   
│   └───Properties
│           AssemblyInfo.cs
│           
└───TestProj.Interface
    │   Interface1.cs
    │   TestProj.Interface.csproj
    │   
    └───Properties
            AssemblyInfo.cs
            

And here's the code reference that does wrong guessing of packages directory location:

private static string GetPackageDirectoryPath(string packagesConfigPath, string packageId, SemanticVersion packageVersion)
{
var packageDirectoryName = packageId + "." + packageVersion;
var candidateFolder = Path.GetDirectoryName(packagesConfigPath);
while (candidateFolder != null)
{
var packageDirectoryPath = Path.Combine(candidateFolder, "packages", packageDirectoryName);
if (Directory.Exists(packageDirectoryPath))
return packageDirectoryPath;
candidateFolder = Path.GetDirectoryName(candidateFolder);
}
return string.Empty;
}

@ivan-sam ivan-sam changed the title Exclude dependency package libraries from lib folder NuProj auto-detection of packages folder is not always working May 18, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant