Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-core/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Visual studio 2015 无法使以下项目可运行(对象引用未设置为对象的实例。)_Visual Studio 2015_Asp.net Core_Asp.net Core Mvc_Asp.net Core 1.0 - Fatal编程技术网

Visual studio 2015 无法使以下项目可运行(对象引用未设置为对象的实例。)

Visual studio 2015 无法使以下项目可运行(对象引用未设置为对象的实例。),visual-studio-2015,asp.net-core,asp.net-core-mvc,asp.net-core-1.0,Visual Studio 2015,Asp.net Core,Asp.net Core Mvc,Asp.net Core 1.0,当我在Visual Studio 2015(更新3)中使用已安装的.NET Core 1.0 SDK和工具(预览2)创建默认web项目,并在还原本地源代码管理更改后重新启动Visual Studio时,我收到以下编译错误: 无法使以下项目可运行:MyDefaultWebProject(.NETCoreApp,版本=v1.0)原因:对象引用未设置为对象的实例 根据Visual Studio,错误位于第262行的C:\Program Files(x86)\MSBuild\Microsoft\Visu

当我在Visual Studio 2015(更新3)中使用已安装的.NET Core 1.0 SDK和工具(预览2)创建默认web项目,并在还原本地源代码管理更改后重新启动Visual Studio时,我收到以下编译错误:

无法使以下项目可运行:MyDefaultWebProject(.NETCoreApp,版本=v1.0)原因:对象引用未设置为对象的实例

根据Visual Studio,错误位于第262行的
C:\Program Files(x86)\MSBuild\Microsoft\VisualStudio\v14.0\DotNet\Microsoft.DotNet.Common.Targets

这一行有以下代码:

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


如何解决这样的问题?

我找到的唯一可行的解决方案是运行
dotnet还原
命令:


之后,Visual Studio中的编译再次成功。

在我的例子中,问题是解决方案中的一个类库项目在我从源代码管理中提取源代码时,按绝对路径引用了
AspNetCore.Identity
库。因此,在
project.fragment.lock.json
文件中生成了错误的路径,解决方案无法生成。 修复了
.csproj
文件中的绝对路径引用,使其正常工作

C:\Dev\*****>dotnet restore

Welcome to .NET Core!
---------------------
Learn more about .NET Core @ https://aka.ms/dotnet-docs. Use dotnet --help to see available commands or go to https://aka.ms/dotnet-cli-docs.
Telemetry
--------------
The .NET Core tools collect usage data in order to improve your experience. The data is anonymous and does not include commandline arguments. The data is collected by Microsoft and shared with the community.
You can opt out of telemetry by setting a DOTNET_CLI_TELEMETRY_OPTOUT environment variable to 1 using your favorite shell.
You can read more about .NET Core tools telemetry @ https://aka.ms/dotnet-cli-telemetry.
Configuring...
-------------------
A command is running to initially populate your local package cache, to improve restore speed and enable offline access. This command will take up to a minute to complete and will only happen once.
Decompressing 100% 2181 ms
Expanding 100% 9113 ms
log  : Restoring packages for C:\Dev\*****\project.json...
log  : Restoring packages for tool 'BundlerMinifier.Core' in C:\Dev\*****\project.json...
log  : Restoring packages for tool 'Microsoft.AspNetCore.Razor.Tools' in C:\Dev\*****\project.json...
log  : Restoring packages for tool 'Microsoft.AspNetCore.Server.IISIntegration.Tools' in C:\Dev\*****\project.json...
log  : Restoring packages for tool 'Microsoft.EntityFrameworkCore.Tools' in C:\Dev\*****\project.json...
log  : Restoring packages for tool 'Microsoft.Extensions.SecretManager.Tools' in C:\Dev\*****\project.json...
log  : Restoring packages for tool 'Microsoft.VisualStudio.Web.CodeGeneration.Tools' in C:\Dev\*****\project.json...
log  : Writing lock file to disk. Path: C:\Dev\*****\project.lock.json
log  : C:\Dev\*****\project.json
log  : Restore completed in 13207ms.