2017-02-18 107 views
6

安装在我的机器上是:奇怪的生成错误的.Net核心项目

  • 的Visual Studio Pro中2015年
  • 的Visual Studio 2015年更新3
  • .NET核心1.0.1工具预览版2

注意:在Windows 10机器和Windows 7机器上会出现生成错误,但生成在另一台Windows 7机器上可以正常工作。

所以我的git克隆从另一个开发一个.net核心项目,当我尝试建立在Visual Studio 2015年我收到错误

“系统找不到Microsoft.DotNet.Common指定的文件。目标管线262"

围棋在C行262:\程序文件(x86)\的MSBuild \微软\ VisualStudio的\ v14.0 \ DOTNET的\ Microsoft.DotNet.Common.Targets线262我看到

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

如果从Microsoft.DotNet.Common.Targets项目中删除此部分建立。

我知道dnx是旧的.Net Core工具,我的猜测是类库中的project.json的东西,遗留给旧的dnx工具以及我已安装的新的1.0.1 Preview 2 .Net Core工具将旧的project.json条目推迟到Microsoft.DotNet.Common.Targets中的旧dnx工具条目,但由于我没有安装dnx工具,所以构建失败,当然,这只是一个猜测。

我已经广泛在网上搜索关于这个问题,我found an article说明把"type": "platform"Microsoft.NETCore.App依赖于project.json但我没有使用依赖,我尝试添加"type": "platform""NETStandard.Library"的依赖,但没有帮助,在这里是我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" 
    ] 
    } 
} 

这里是生成输出:

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 ========== 
+0

给VS 2017年一试。旧工具不再由Microsoft积极维护。 –

+0

@LexLi VS 2015被认为是旧的工具?为什么是Microsoft Core安装说明的第一步:“下载Visual Studio 2015”? https://www.microsoft.com/net/core#windowsvs2015 –

+0

只是因为它还没有3月7日。他们可能不想在这么短的时间内更新两次页面。 –

回答

10

该错误消息完全是误导性的,它是我的postcompile cmd将库作为nuget包发布到我自己的nuget服务器,该服务器失败:

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

即CMD试图调用C:\Program Files (x86)\NuGet\nuget.exe

正如我所说的,我克隆该项目并没有创造它,谁创造了这个项目的开发商已安装C:\Program Files (x86)\NuGet\nuget.exe

我只有C:\Program Files (x86)\NuGet,没有nuget.exe,该文件夹存在,因为我安装了Visual Studio 2015 nuget扩展,并且.vsix文件居住在那里但没有nuget.exe。

我只是下载nuget.exe here最新版本(V3.5.0)和放置在我的postcompile CMD希望它是:C:\ Program Files文件(x86)的\的NuGet

+1

很高兴看到你找到原因,但推荐移动到最新的SDK作为预览版本即将过期。 –

+0

伟大的提示,也是我的原因。希望VS2017中的csproj能够回归更好的SDK – ZoolWay

0

尝试......

  1. 关闭Visual Studio的
  2. 下载SDK 1.1,https://www.microsoft.com/net/core#windowscmd
  3. 重新打开项目在Visual Studio
  4. 删除project.lock.json(等待恢复)
  5. 重建
+0

我已经有.NET 1.1的核心安装,我删除了.json.lock,等待恢复和后续的构建仍然未能 –

+0

尝试添加运行部分(下面的框架部分): –

+0

“运行环境”:{ “win10-64” :{} }, –