7

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 ==========
8
  • Give VS 2017 a try. Old tooling is no longer actively maintained by Microsoft. Commented Feb 18, 2017 at 12:42
  • @LexLi VS 2015 is considered old tooling? Why is the first step of Microsoft's installation instructions for .NET Core: "Download Visual Studio 2015"? microsoft.com/net/core#windowsvs2015 Commented Feb 19, 2017 at 17:11
  • simply because it is not yet March 7. They probably do not want to update the pages twice in such a short period of time. Commented Feb 19, 2017 at 17:16
  • @LexLi I am skeptical that VS 2015 is an issue,VS 2015 should just be using the installed .NET Core tooling, in my case: .NET Core 1.0.1 tools Preview 2 Commented Feb 19, 2017 at 17:35
  • 1
    Then clearly it is an issue of preview 2. As the whole tool chain is moving to VS2017, you will soon be needing it daily. Commented Feb 20, 2017 at 20:55

3 Answers 3

10

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

Sign up to request clarification or add additional context in comments.

2 Comments

Glad to see you find the cause, but moving to latest SDK is recommended as the preview builds are expiring.
Great hint, was the reason in my case too. Hoping for better SDK with the comeback of csproj in VS2017
0

Try this...

  1. Close Visual Studio
  2. Download the 1.1 SDK, https://www.microsoft.com/net/core#windowscmd
  3. Reopen project in Visual Studio
  4. Delete the project.lock.json (wait for restore)
  5. Rebuild

5 Comments

I already have .net core 1.1 installed, I have deleted the .json.lock and waited for restore and the subsequent build still failed
try adding the runtime section (below the frameworks section):
"runtimes" : { "win10-x64": {} },
occurs on Windows 7 as well
tried adding the runtimes entry, no luck, I have added the build output to my question
0

I have produced the scenerio. You could restore the package altogether. Follow the steps: Right click on Project-> Click on Resotre Packages And check your output.

Hope this would resolve your issue.

1 Comment

Also, i recommend you to use Visual Studio 2017 community or professional for high version of .Net Core 2x .

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.