Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Strange Build Error .Net Core Project

Installed on my machine is:

  • Visual Studio Pro 2015
  • Visual Studio 2015 Update 3
  • .NET Core 1.0.1 tools Preview 2

Note: Build error occurs on a Windows 10 machine and a Windows 7 machine, but build does work on another Windows 7 machine.

So I git clone a .Net Core project from another developer and when I try to build in Visual Studio 2015 I am getting the error

"The system cannot find the file specified in Microsoft.DotNet.Common.Targets line 262"

Go to line 262 in C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\DotNet\Microsoft.DotNet.Common.Targets line 262 I see

    <Dnx
  RuntimeExe="$(SDKToolingExe)"
  Condition="'$(_DesignTimeHostBuild)' != 'true'"
  ProjectFolder="$(MSBuildProjectDirectory)"
  Arguments="$(_BuildArguments)"
  />

If delete this section from Microsoft.DotNet.Common.Targets the project builds.

I know dnx is the old .Net Core tooling, my guess is something in the project.json for the class library is legacy to the old dnx tooling and the new 1.0.1 Preview 2 .Net Core tooling I have installed is deferring that legacy project.json entry to the old dnx tooling entry in Microsoft.DotNet.Common.Targets but since I do not have dnx tooling installed, the build fails, of course, this is just a guess.

I have extensively searched online about this issue, I found an article stating to put "type": "platform" for Microsoft.NETCore.App dependency in the project.json but I am not using that dependency, I tried adding "type": "platform" to my "NETStandard.Library" dependency but that did not help, here is my project.json:

{
  "version": "1.0.1-*",

  "dependencies":
  {
    "Microsoft.AspNetCore.Mvc.Abstractions": "1.1.0",
    "Microsoft.AspNetCore.Mvc.Core": "1.1.0",
    "NETStandard.Library": "1.6.1",
    "TSO.ProductItemList.Model": "1.0.2"
  },

  "frameworks":
  {
    "netstandard1.6":
    {
      "imports": "dnxcore50"
    }
  },

  "scripts":
  {
    "postcompile":
    [
      "dotnet pack --no-build --configuration %compile:Configuration%",
      "\"C:\\Program Files (x86)\\NuGet\\nuget\" push \"%project:Directory%\\bin\\%compile:Configuration%\\%project:Name%.%project:Version%.nupkg\" -s http://foo/NugetServer/ -apikey testkey"
    ]
  }
}

Here is the build output:

1>------ Build started: Project: TSO.ProductItemList.Model, Configuration: Debug Any CPU ------
1>  C:\Program Files\dotnet\dotnet.exe build "C:\projects\tsl\ProductItemList\src\TSO.ProductItemList.Model" --configuration Debug --no-dependencies
1>  Project TSO.ProductItemList.Model (.NETStandard,Version=v1.6) will be compiled because project is not safe for incremental compilation. Use --build-profile flag for more information.
1>  Compiling TSO.ProductItemList.Model for .NETStandard,Version=v1.6
1>  Producing nuget package "TSO.ProductItemList.Model.1.0.2" for TSO.ProductItemList.Model
1>  TSO.ProductItemList.Model -> C:\projects\tsl\ProductItemList\src\TSO.ProductItemList.Model\bin\Debug\TSO.ProductItemList.Model.1.0.2.nupkg
1>  Producing nuget package "TSO.ProductItemList.Model.1.0.2.symbols" for TSO.ProductItemList.Model
1>  TSO.ProductItemList.Model -> C:\projects\tsl\ProductItemList\src\TSO.ProductItemList.Model\bin\Debug\TSO.ProductItemList.Model.1.0.2.symbols.nupkg
1>C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\DotNet\Microsoft.DotNet.Common.Targets(262,5): error : The system cannot find the file specified
2>------ Build started: Project: TSO.ProductItemList.Client, Configuration: Debug Any CPU ------
2>  C:\Program Files\dotnet\dotnet.exe build "C:\projects\tsl\ProductItemList\src\TSO.ProductItemList.Client" --configuration Debug --no-dependencies
2>  Project TSO.ProductItemList.Client (.NETStandard,Version=v1.6) will be compiled because project is not safe for incremental compilation. Use --build-profile flag for more information.
2>  Compiling TSO.ProductItemList.Client for .NETStandard,Version=v1.6
2>  Producing nuget package "TSO.ProductItemList.Client.1.0.1" for TSO.ProductItemList.Client
2>  TSO.ProductItemList.Client -> C:\projects\tsl\ProductItemList\src\TSO.ProductItemList.Client\bin\Debug\TSO.ProductItemList.Client.1.0.1.nupkg
2>  Producing nuget package "TSO.ProductItemList.Client.1.0.1.symbols" for TSO.ProductItemList.Client
2>  TSO.ProductItemList.Client -> C:\projects\tsl\ProductItemList\src\TSO.ProductItemList.Client\bin\Debug\TSO.ProductItemList.Client.1.0.1.symbols.nupkg
2>C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\DotNet\Microsoft.DotNet.Common.Targets(262,5): error : The system cannot find the file specified
========== Build: 0 succeeded, 2 failed, 0 up-to-date, 0 skipped ==========
like image 673
Brian Ogden Avatar asked Feb 18 '17 00:02

Brian Ogden


1 Answers

The error message was entirely misleading, it was my postcompile cmd to publish the library as a nuget package to my own nuget server that was failing:

  "scripts":
  {
    "postcompile":
    [
      "dotnet pack --no-build --configuration %compile:Configuration%",
      "\"C:\\Program Files (x86)\\NuGet\\nuget\" push \"%project:Directory%\\bin\\%compile:Configuration%\\%project:Name%.%project:Version%.nupkg\" -s http://foo/NugetServer/ -apikey testkey"
    ]
  }

That cmd is trying to call C:\Program Files (x86)\NuGet\nuget.exe

As I said, I cloned this project and did not create it, the developer who created the project has C:\Program Files (x86)\NuGet\nuget.exe installed.

I only had C:\Program Files (x86)\NuGet, no nuget.exe, the folder existed because I have the Visual Studio 2015 nuget extension installed and the .vsix file lives there but no nuget.exe.

I simply downloaded nuget.exe here, latest (v3.5.0) and placed where my postcompile cmd expected it to be: C:\Program Files (x86)\NuGet

like image 82
Brian Ogden Avatar answered Sep 22 '22 19:09

Brian Ogden