baseclass / Contrib.Nuget

Extending nuget with nuget packages
MIT License
30 stars 21 forks source link

Baseclass.contrib.nuget.output 2.3.0 fails when building using dotnet build #35

Open bensonmve opened 7 years ago

bensonmve commented 7 years ago

Hi,

I have an issue when building an VS2017 project using the dotnet-build command-line.

This is what I have in the csproj file:

<PropertyGroup>
    <TargetFramework>net452</TargetFramework>
    <AssemblyName>JW.project.ProjectName</AssemblyName>
    <OutputType>Exe</OutputType>
    <PackageId>JW.project.ProjectName</PackageId>
</PropertyGroup>

<ItemGroup>
    <PackageReference Include="Baseclass.Contrib.Nuget.Output" Version="2.3.0" />
    ....
</ItemGroup>

VS2017 builds it but when executing dotnet build path\JW.project.ProjectName\JW.project.ProjectName.csproj --configuration Release I get this:

C:\Users\xxxxxxx\.nuget\packages\baseclass.contrib.nuget.output\2.3.0\build\net40\Baseclass.Contrib.Nuget.Output.targets(66,5): 
error MSB4018: The "PackageRetrievalTask" task failed unexpectedly. [C:\src\Projects\src\JW.project.ProjectName\JW.project.ProjectName.csproj]
error MSB4018: System.IO.FileNotFoundException: Could not load file or assembly 'System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. The specified file was not found. [C:\src\Projects\src\JW.project.ProjectName\JW.project.ProjectName.csproj]
error MSB4018: File name: 'System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' [C:\src\Projects\src\JW.project.ProjectName\JW.project.ProjectName.csproj]
error MSB4018:    at Baseclass.Contrib.Nuget.Output.Build.PackageRetrievalTask.Execute() [C:\src\Projects\src\JW.project.ProjectName\JW.project.ProjectName.csproj]
error MSB4018:    at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute() [C:\src\Projects\src\JW.project.ProjectName\JW.project.ProjectName.csproj]
error MSB4018:    at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__25.MoveNext() [C:\src\Projects\src\JW.project.ProjectName\JW.project.ProjectName.csproj]
    0 Warning(s)
    1 Error(s)

I can't figure out why it can't find it.

Steps to reproduce

  1. In VS2017, create a console app (.Net framework) targeting Net461
  2. Add Baseclass.Contrib.Nuget.Output to it
  3. Build the project using the command-line (dotnet build)

It will raise the FileNotFoundException.

romerod commented 7 years ago

Thanks for the detailed issue, i'll take a look.

Does it build from within VS?

bensonmve commented 7 years ago

It builds when using the Build button in VS but when using Package Manager Console with dotnet command, it does not.

eprafulla commented 7 years ago

Hi,

I am having a similar issue when using VS2017 for ASP.NET Core 1.1 project targeting full framework net46 (it's a core project still pointing to full framework, as most of the dependencies are yet to be available for 'core'. I was following this)

The project builds fine in VS 2017 after adding Baseclass.contrib.nuget.output 2.3.0 from nuget. But it fails on command line with same error as mentioned by @bensonmve.

Thanks in advance.

fabiosalvi commented 7 years ago

@bensonmve @eprafulla see issue #39

romerod commented 7 years ago

dotnet cli is currently not supported

tinuroth commented 1 year ago

We will not have much choice other than retiring Baseclass.contrib.nuget.output from our projects if it keeps failing .NET SDK builds. And this is what we seem to experience, seeing our builds fail on VS 2022, Rider and TeamCity .NET runner builds. So, if you want to make Baseclass.contrib future-proof, then I guess you will have to move now. This issue is soon to turn six years of age.

For now, we will be turning away from Baseclass.contrib, removing it as a dependency from our native NuGet packages, instead going with a particular .targets files included in the package and referred to from its .nuspec, taking care of copying native DLLs to the output/build folder. For whomever interested, e.g. see here:

The old way with Baseclass.contrib.nuget.output seemed easier, but yes, who does not move is left behind. Sorry.