Strange .NET Core Project Build Error

Installed on my machine:

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

Note. A build error occurs on a computer running Windows 10 and on a computer that is running Windows 7, but the assembly works on another computer that is running Windows 7.

So, I git cloned the .Net Core project from another developer, and when I try to build Visual Studio 2015, I get an 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 you remove this section from the Microsoft.DotNet.Common.Targets project assembly.

I know that dnx is an old .Net Core utility, my hunch is something in the project. json for the class library is a legacy of the old dnx snap-in, and the new utility 1.0.1 Preview 2..Net Core, which I installed by deferring this obsolete project.json entry to the old dnx tool entry in Microsoft.DotNet.Common.Targets, but since I don’t have dnx snap installed, the assembly does not work, of course, this is just an assumption.

I searched in detail on the Internet about this problem, I found an article that says how to add "type": "platform" to Microsoft.NETCore.App in the project. json, but I do not use this 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 result:

 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 ========== 
+6
source share
2 answers

The error message was completely misleading, so my postcompile cmd published the library as a nuget package on my own nuget server, which failed:

  "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" ] } 

This 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 installed C:\Program Files (x86)\NuGet\nuget.exe .

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

I just downloaded nuget.exe here , the last (v3.5.0) and placed where my postcompile cmd was expecting this: C: \ Program Files (x86) \ NuGet

+10
source

Try it...

0
source

Source: https://habr.com/ru/post/1015079/


All Articles