无法使以下项目可运行(对象引用未设置为对象的实例.) [英] Failed to make the following project runnable (Object reference not set to an instance of an object.)

查看:96
本文介绍了无法使以下项目可运行(对象引用未设置为对象的实例.)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

When I create default web project in Visual Studio 2015 (Update 3) with installed .NET Core 1.0 SDK and Tooling (preview 2) and restart the Visual Studio after reverting local source control changes I am getting the following compilation error:

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

Failed to make the following project runnable: MyDefaultWebProject (.NETCoreApp,Version=v1.0) reason: Object reference not set to an instance of an object.

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

According to Visual Studio the error is located in C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\DotNet\Microsoft.DotNet.Common.Targets on line 262

在这一行上,有以下代码:

On this line there is the following code:

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

如何解决此问题?

推荐答案

我设法找到的唯一可行的解​​决方案是运行dotnet restore 命令:

The only working solution I managed to find is to run the dotnet restore command:

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.

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

after which the compilation in Visual Studio is successful again.

这篇关于无法使以下项目可运行(对象引用未设置为对象的实例.)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆