Microsoft.DotNet.Common.Targets(262,5):错误:对象引用未设置为对象实例

本文关键字:对象引用 错误 实例 对象 设置 Targets Common DotNet Microsoft | 更新日期: 2023-09-27 17:58:53

我正在将库从.Net 4.5迁移到.net core。我已经有了.xproj,但当我运行dotnet build时,我会得到错误:

Microsoft.DotNet.Common.Targets(262,5):错误:对象ct引用未设置为对象实例。

这是我的project.json文件:

{
  "version": "1.0.0",
  "frameworks": {
    "net45": {
      "frameworkAssemblies": {
        "System.Collections.Concurrent": {
          "type": "build"
        }
      }
    },
    "netstandard1.6": {
      "imports": "dnxcore50",
      "dependencies": {
        "NETStandard.Library": "1.6.0"
      }
    }
  }
}

我缺什么了吗?

Microsoft.DotNet.Common.Targets(262,5):错误:对象引用未设置为对象实例

从命令行运行dotnet restore有效,但在Visual Studio 2015 Update 3中无效。我怀疑这与拥有私人裸体订阅源有关。

如果在远程服务器上的TFS构建中出现此错误,则仍然可以手动运行dotnet restore

例如。我切换到C:'BUILD-AGENT'_work'1's'RR.CRM并运行dotnet restore

仍然不太确定VS什么时候会这样做或不这样做,但就目前而言,这是一个行之有效的快速解决方案。

我在VS2015(社区)中遇到了同样的问题,从零开始启动ASP.NET MVC Core项目并更新到Core 1.1.1。由于某种未知的原因,Nuget没有100%更新引用;其中一些仍然"落后一步"。

下面你可以找到我的project.json文件

{
  "dependencies": {
    "Microsoft.AspNetCore.Razor.Tools": {
      "version": "1.1.0-preview4-final",
      "type": "build"
    },
    "Microsoft.AspNetCore.Routing": "1.1.1",
    "Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore": "1.1.1",
    "Microsoft.AspNetCore.Authentication.Cookies": "1.1.1",
    "Microsoft.AspNetCore.Diagnostics": "1.1.1",
    "Microsoft.AspNetCore.Identity.EntityFrameworkCore": "1.1.1",
    "Microsoft.AspNetCore.Mvc": "1.1.2",
    "Microsoft.AspNetCore.Server.IISIntegration": "1.1.1",
    "Microsoft.AspNetCore.Server.Kestrel": "1.1.1",
    "Microsoft.AspNetCore.StaticFiles": "1.1.1",
    "Microsoft.EntityFrameworkCore.SqlServer": "1.1.1",
    "Microsoft.EntityFrameworkCore.SqlServer.Design": {
      "version": "1.1.1",
      "type": "build"
    },
    "Microsoft.EntityFrameworkCore.Tools": {
      "version": "1.1.0",
      "type": "build"
    },
    "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.1.1",
    "Microsoft.Extensions.Configuration.Json": "1.1.1",
    "Microsoft.Extensions.Configuration.UserSecrets": "1.1.1",
    "Microsoft.Extensions.Logging": "1.1.1",
    "Microsoft.Extensions.Logging.Console": "1.1.1",
    "Microsoft.Extensions.Logging.Debug": "1.1.1",
    "Microsoft.Extensions.Options.ConfigurationExtensions": "1.1.1",
    "Microsoft.NETCore.App": {
      "version": "1.1.1",
      "type": "platform"
    },
    "Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.1.0",
    "Microsoft.VisualStudio.Web.CodeGeneration.Tools": {
      "version": "1.1.0-preview4-final",
      "type": "build"
    },
    "Microsoft.VisualStudio.Web.CodeGenerators.Mvc": {
      "version": "1.1.0",
      "type": "build"
    }
  },
  "tools": {
    "BundlerMinifier.Core": "2.4.337",
    "Microsoft.AspNetCore.Razor.Tools": "1.1.0-preview4-final",
    "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final",
    "Microsoft.EntityFrameworkCore.Tools": "1.1.0",
    "Microsoft.Extensions.SecretManager.Tools": "1.0.0",
    "Microsoft.VisualStudio.Web.CodeGeneration.Tools": {
      "version": "1.1.0-preview4-final",
      "imports": [
        "portable-net45+win8"
      ]
    }
  },
  "frameworks": {
    "netcoreapp1.0": {
      "imports": [
        "dotnet5.6",
        "portable-net45+win8"
      ]
    }
  },
  "buildOptions": {
    "emitEntryPoint": true,
    "preserveCompilationContext": true
  },
  "runtimeOptions": {
    "configProperties": {
      "System.GC.Server": true
    }
  },
  "publishOptions": {
    "include": [
      "wwwroot",
      "**/*.cshtml",
      "appsettings.json",
      "web.config"
    ]
  },
  "scripts": {
    "prepublish": [ "bower install", "dotnet bundle" ],
    "postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ]
  }
}

Microsoft.AspNetCore.Razor.Tools未正确更新。CCD_ 11和CCD_。