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?
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"
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With