premake / premake/premake-core

Nuget keyword not respecting nuget.config, project location, actual lib names

Open
#569 22 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug help wanted vs20xx
Dominant language
C
Stars
3.6k
Forks
654
Avg merge
1d 1h
Merged PRs (30d)
13

Description

Hi. I'm currently evaluating premake 5 as a possible new build system at work. So far I'm liking it lots.

I'm having some trouble getting nuget dependencies working though. The first thing I tried to do with it was add a dependency on NUnit 3.4.1 in one project of a vs2015 multi-project solution. I realize it's bleeding edge days for premake 5 and I may have to invest some effort into making it work, but the user guide says if something's not working as you expect, submit a ticket. Also from reading some of your dev discussions and pull requests I think this probably touches on larger questions.

So here goes. :)

  1. There appear to be assumptions that a NuGet package contains only one relevant lib and that it has the same name as the package. These are not always the case, but as far as I can tell the .nupkg file doesn't actually tell you which files you want; it might actually be correct to just find and use all the DLLs in the appropriate subdirectory of the package.

  2. The content of the generated packages.config file is correct, but it is placed next to the .sln file rather than the .csproj that actually has the dependency.

  3. The properties added to the .csproj are not correct; in addition to #1 above it adds dependencies for every .net framework version, and fails to add the file include for packages.config. Because of this the package will never be downloaded and the build will fail.

  4. If you have a nuget.config file set up so that all your packages download to one nice clean place, that location is not respected. See http://docs.nuget.org/release-notes/nuget-2.1#Specify_%e2%80%98packages%e2%80%99_Folder_Location - there are several places this config can go. (Actually, I'd be totally cool with premake generating the nunit.config file next to the .sln as long as it allowed specifying extra package sources as well as a custom repository path.)

Here are the diffs to the .csproj file if I add the NuGet package manually, using the solution generated from the attached repro case with the nuget line commented out. This is what should happen. Also note that it's using the .net 4.5 version even though I use 4.6, because there is no 4.6 version in the NuGet package.

42a43,47
>     <Reference Include="nunit.framework, Version=3.4.1.0, Culture=neutral, PublicKeyToken=2638cd05610744eb, processorArchitecture=MSIL">
>       <SpecificVersion>False</SpecificVersion>
>       <HintPath>..\..\..\nuget_packages\downloaded\NUnit.3.4.1\lib\net45\nunit.framework.dll</HintPath>
>       <Private>True</Private>
>     </Reference>
57a63,65
>   </ItemGroup>
>   <ItemGroup>
>     <None Include="packages.config" />

And here is what actually happens:

43a44,54
>     <Reference Include="NUnit">
>       <HintPath Condition="Exists('..\..\packages\NUnit.3.4.1\lib\net10\NUnit.dll')">..\..\packages\NUnit.3.4.1\lib\net10\NUnit.dll</HintPath>
>       <HintPath Condition="Exists('..\..\packages\NUnit.3.4.1\lib\net11\NUnit.dll')">..\..\packages\NUnit.3.4.1\lib\net11\NUnit.dll</HintPath>
>       <HintPath Condition="Exists('..\..\packages\NUnit.3.4.1\lib\net20\NUnit.dll')">..\..\packages\NUnit.3.4.1\lib\net20\NUnit.dll</HintPath>
>       <HintPath Condition="Exists('..\..\packages\NUnit.3.4.1\lib\net30\NUnit.dll')">..\..\packages\NUnit.3.4.1\lib\net30\NUnit.dll</HintPath>
>       <HintPath Condition="Exists('..\..\packages\NUnit.3.4.1\lib\net35\NUnit.dll')">..\..\packages\NUnit.3.4.1\lib\net35\NUnit.dll</HintPath>
>       <HintPath Condition="Exists('..\..\packages\NUnit.3.4.1\lib\net40\NUnit.dll')">..\..\packages\NUnit.3.4.1\lib\net40\NUnit.dll</HintPath>
>       <HintPath Condition="Exists('..\..\packages\NUnit.3.4.1\lib\net45\NUnit.dll')">..\..\packages\NUnit.3.4.1\lib\net45\NUnit.dll</HintPath>
>       <HintPath Condition="Exists('..\..\packages\NUnit.3.4.1\lib\net46\NUnit.dll')">..\..\packages\NUnit.3.4.1\lib\net46\NUnit.dll</HintPath>
>       <Private>True</Private>
>     </Reference>

GitHub won't let me attach a zip file, so for now my repro case example is here: https://drive.google.com/open?id=0B6BLRF-3H7q1ckZtZTg3N3BzUEk - I'm using premake5 built from master/head with VS2015 on Windows 7.

(My next question after getting this working would be, how can I get a path into a NuGet package so I can invoke executables that are distributed that way?)

Also: Hi, Tom! :)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the VS2015 solution from the linked repro case and inspect the generated .csproj and packages.config alongside the nuget.config settings. Compare the generated project with the manual diff in the issue. Done means package location, package sources, framework selection, actual library names, project-relative packages.config placement, and required project includes all behave as described.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, lua
Domain
build-system, devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.