Appsettings.Production.json now requiring ConnectionStrings in VS2017 RC


  • 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. 

    This is happening when I am publishing to Microsoft Azure.

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

    Thanks in advance!

    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 
    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 ==========

    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": {

    Edit 3: OK, it looks like a 'Connection String' is now required in the appsettings.Production.json file.

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

    Monday, February 06, 2017 2:10 PM

All replies

  • Hi ZombiesWithCoffee,

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

    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.

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



    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact

    • Proposed as answer by qing__Moderator Thursday, February 09, 2017 5:41 AM
    Tuesday, February 07, 2017 5:23 AM
  • I had the same error with an appsetting.Production.json file but no DefaultConnection enty; I had named the connection string entries differently. Once I added a DefaultConnection, it worked.
    Wednesday, March 28, 2018 3:09 PM