【发布时间】:2017-07-07 15:54:28
【问题描述】:
在我的机器上安装的是:
- Visual Studio Pro 2015
- Visual Studio 2015 更新 3
- .NET Core 1.0.1 工具预览版 2
注意:构建错误在 Windows 10 机器和 Windows 7 机器上发生,但构建在另一台 Windows 7 机器上运行。
所以我从另一个开发人员那里 git 克隆了一个 .Net Core 项目,当我尝试在 Visual Studio 2015 中构建时,我收到了错误
“系统找不到Microsoft.DotNet.Common.Targets第262行指定的文件”
转到 C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\DotNet\Microsoft.DotNet.Common.Targets 第 262 行中的第 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 声明在 project.json 中将 "type": "platform" 用于 Microsoft.NETCore.App 依赖项,但我没有使用该依赖项,我尝试将 "type": "platform" 添加到我的 @987654327 @ 依赖,但这没有帮助,这是我的 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 ==========
【问题讨论】:
-
试试 VS 2017。 Microsoft 不再积极维护旧工具。
-
@LexLi VS 2015 被认为是旧工具?为什么微软的 .NET Core 安装说明的第一步是:“下载 Visual Studio 2015”? microsoft.com/net/core#windowsvs2015
-
只是因为现在还不是 3 月 7 日。他们可能不想在这么短的时间内两次更新页面。
-
@LexLi 我怀疑 VS 2015 是个问题,VS 2015 应该只是使用已安装的 .NET Core 工具,在我的情况下:.NET Core 1.0.1 工具预览 2
-
那么显然是预览版2的问题。随着整个工具链正在向VS2017移动,您很快就会每天都需要它。
标签: c# .net visual-studio asp.net-core .net-core