Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TransformAppSettings Failure during VS 2019 Web Deploy

I have a project that I develop locally and run with a local DB.

I have a production version of this project running on a server with its DB hosted on another server.

I've been able to upload my project several times directly from VS 2019 Web Deploy to my hosting server with no problems. Now I receive the following error:

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()

I haven't touched my connection string in my publishing profile from when it last worked fine.

Any idea what causes this?

like image 648
Graham Meehan Avatar asked Dec 22 '22 22:12

Graham Meehan


1 Answers

This issue was caused by not having my connection string in appsettings.Development.json.

It was in appsettings.json, but not in the development settings specifically.

I added the following to appsettings.Development.json:

"ConnectionStrings": {
    "DefaultConnection": "Server=(localdb)\\mssqllocaldb;Database=xxx;Trusted_Connection=True;MultipleActiveResultSets=true"
  }
like image 99
Graham Meehan Avatar answered Jan 12 '23 01:01

Graham Meehan