Appsettings.Production.json现在需要VS2017 RC中的ConnectionStrings [英] Appsettings.Production.json now requiring ConnectionStrings in VS2017 RC

查看:80
本文介绍了Appsettings.Production.json现在需要VS2017 RC中的ConnectionStrings的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

每次更新Visual Studio核心后,我都需要花几天时间来修复最新的bug。  这次是TransformAppSettings期间UpdateDestinationConnectionStringEntries方法的NullReferenceException。 

After every new update of Visual Studio core, I need to spend a few days on repairing the latest bug.  This time it's a NullReferenceException on the UpdateDestinationConnectionStringEntries method during TransformAppSettings. 

当我发布到Microsoft Azure时会发生这种情况。

网页对这个错误非常安静,所以有人对我应该从哪里开始寻找任何建议吗?

The web is pretty quiet about this error, so does anyone have any suggestions on where I should start looking?

谢谢提前!

更新1:删除appsettings.Production.json文件会删除此特定错误,因此必须与此相关。  这是我在过去版本中成功使用的文件,因此不确定是什么原因导致的。

Update 1: Removing the appsettings.Production.json file removes this particular error, so it must be related to that.  It's the same file that I've used successfully in past versions, so not sure what is causing that yet.

1>------ Build started: Project: SafeInvestigation.Domain, Configuration: Release Any CPU ------
2>------ Build started: Project: SafeInvestigation.Presentation, Configuration: Release Any CPU ------
2>SafeInvestigation.Presentation -> D:\GitHub\SafeInvestigation\SafeInvestigation.Presentation\bin\Release\netcoreapp1.0\SafeInvestigation.Presentation.dll
3>------ Build started: Project: SafeInvestigation, Configuration: Release Any CPU ------
3>SafeInvestigation -> D:\GitHub\SafeInvestigation\SafeInvestigation\bin\Release\netcoreapp1.0\SafeInvestigation.dll
4>------ Publish started: Project: SafeInvestigation, Configuration: Release Any CPU ------
C:\Program Files (x86)\Microsoft SDKs\TypeScript\2.1\tsc.exe  --noEmitOnError --listEmittedFiles --locale en-US
C:\Program Files (x86)\Microsoft SDKs\TypeScript\2.1\tsc.exe  --noEmitOnError --listEmittedFiles --locale en-US
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\Roslyn\csc.exe /noconfig /unsafe- /nowarn:1701,1702,1705,2008 /nostdlib+ 
	/errorreport:prompt /warn:4 /define:TRACE;NETCOREAPP1_0;DEBUG /errorendlocation /preferreduilang:en-US 
	/reference:C:\Users\XXX\.nuget\packages\microsoft.visualstudio.web.codegeneration.design\1.0.0-msbuild3-final\lib\netcoreapp1.0\dotnet-aspnet-codegenerator-design.dll 
	/reference:C:\Users\XXX\.nuget\packages\linqkit.microsoft.entityframeworkcore\1.1.9\lib\netstandard1.3\LinqKit.Microsoft.EntityFrameworkCore.dll 
	...(more)
SafeInvestigation -> D:\GitHub\SafeInvestigation\SafeInvestigation\bin\Debug\netcoreapp1.0\SafeInvestigation.dll
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Sdks\Microsoft.NET.Sdk.Publish\build\netstandard1.0\TransformTargets\Microsoft.NET.Sdk.Publish.TransformFiles.targets(76,5): Error MSB4018: The "TransformAppSettings" task failed unexpectedly.
System.NullReferenceException: Object reference not set to an instance of an object.
   at Microsoft.NET.Sdk.Publish.Tasks.AppSettingsTransform.UpdateDestinationConnectionStringEntries(String destinationAppSettingsFilePath, ITaskItem[] destinationConnectionStrings)
   at Microsoft.NET.Sdk.Publish.Tasks.TransformAppSettings.TransformAppSettingsInternal()
   at Microsoft.NET.Sdk.Publish.Tasks.TransformAppSettings.Execute()
   at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
   at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext()

4>Publish failed due to build errors. Check the error list for more details.
========== Build: 3 succeeded or up-to-date, 0 failed, 0 skipped ==========
========== Publish: 0 succeeded, 1 failed, 0 skipped ==========

编辑2:我减少了我的appsettings和appsettings。现在生产基本没什么。  并且在发布期间,如果Production.json文件存在,它仍然会失败。

Edit 2: I've reduced my appsettings and appsettings.Production down to basically nothing now.  And during publication, it still fails if the Production.json file exists.

{
  "SmsSettings": {
  }
}

编辑3:好的,现在appsettings.Production.json文件中需要'连接字符串'。

  "ConnectionStrings": {
    "DefaultConnection": "Server=(localdb)\\mssqllocaldb;Database=xxx;Trusted_Connection=True;MultipleActiveResultSets=true"
  }





$







推荐答案

嗨ZombiesWithCoffee,

Hi ZombiesWithCoffee,

很高兴知道你已经通过在appsettings.production.json文件中添加连接字符串解决了你的问题。

Glad to know you have resolved your issue via adding a connection string to the appsettings.production.json file.

在我这边,我创建了一个新的 .Net Core Web项目并将其发布到Azure而没有任何问题。那么请分享一下我的哪个类型项目?请创建一个新项目并将其发布到Azure以查看结果。

In my side, I have created a new .Net Core Web project and publish it to the Azure without any problems. So please share me which type project? And please create a new project and publish it to Azure to see the results.

并且请将您的VS2017 RC更新到最新版本(VisualStudio / 15.0.0-RC.3 + 26127.3) 。

And Please update your VS2017 RC to the latest version (VisualStudio/15.0.0-RC.3+26127.3).

此致,

奥斯卡


这篇关于Appsettings.Production.json现在需要VS2017 RC中的ConnectionStrings的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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