Pass variable when publishing Asp.Net Core application

I have the following on an ASP.NET Core 2.2 project file: <Target Name=”PublishRunWebpack” AfterTargets=”ComputeFilesToPublish”> <Exec WorkingDirectory=”$(SpaRoot)” Command=”npm run build –prod” /> </Target> When publishing the application, using dotnet publish, instead of using: npm run build –prod I need to be able to specify if I should run: npm run build –prod.machine-1 or npm run build…

How to use json.net for asp.net core model binding on POST requests?

I’ve seen this other question with no answer. I need to deserialize with newtonsoft because I have circular references loop handling when sending the data to the client: services.AddMvc() .AddJsonOptions(options => { options.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver(); options.SerializerSettings.PreserveReferencesHandling = PreserveReferencesHandling.Objects; options.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Serialize; options.SerializerSettings.NullValueHandling = NullValueHandling.Ignore; }); This produces JSON objects with $id and $ref that…

Asp.net Core MVC – obtaining dependency during app shutdown

I’m developing a web app using ASP.net Core MVC 2.2, and in my Startup class I’m registering a dependency injection of type MyService, like so: public void ConfigureServices(IServiceCollection services) { //Inject dependency services.AddSingleton<MyService>(); //…other stuff… } This works correctly. However, I need to retrieve the instance of MyService during application shutdown, in order to do…