Need runtimeOptions for dotnet-publish
Currently we have compilationOptions which specify inputs to dotnet-compile. Similarly we need runtimeOptions which dotnet-publish converts into a config file for the corehost.
See the ask https://github.com/dotnet/cli/issues/423
@piotrpMSFT @Sridhar-MS, To fix this issue, I am planning to enable SERVER_GC by default in corehost and optionally provide an environment variable which will override the default setting. This would be a breaking change (not visible but uses different GC) for the CLI commands since console apps don't want this change. This gives great perf wins for ASP.NET scenarios
I would prefer dotnet-publish captures user intent regarding runtime from project.json and emits a config file for the host. This is similar to the exe.config in Desktop CLR. The format can start simple as
runtime.config:
KEY1=VALUE1
KEY2=VALUE2
project.json:
{
...
"runtimeOptions" : {
"SERVER_GC": "1",
"GC_ALLOW_VERY_LARGE_OBJECTS": "..."
},
...
}
/Cc @gkhanna79
Why not just put it in the config file directly? It's basically app.config
@davidfowl Which config file are you referring to? and does that exist for regular console apps?
The bug suggests that the runtimes options get converted into a config file that the runtime reads, or did I misread that. Why do we need any section in project.json if that's the case?
I do dotnet new and publish and got hello world. How will the CLR decide between server GC or client GC? If you require intervention (manually adding app.config) for every little hello world, that doesn't sound good.
What is app.config? Does it exist for console apps or is it for ASP.NET? If latter, are you suggesting we set the default to be client GC and ASP.NET use app.config to have server gc?
/Cc @krwq, @brthor, @anurse
I'm saying project.json isn't a runtime artifact anymore and I don't see the point storing data in there and transforming it into a runtime.config file. The app.config file was an analogy.
@davidfowl Where else would we store this info where it's easily accessible to the user? Would they need to create the runtime.config themselves? How do we then know to publish that file with the app?
@schellap Would we still have a default state where these options don't need to be specified?
Yea, project.json is not intended for runtime consumption. It's the wrong artifact.
We need a design for a runtime / application config concept.
@blackdwarf can you take a stab at this?
With CoreRT the runtime is both static and dynamic. So your solution (say, config file) should be available statically (to dotnet-compile-native) and also at runtime.
@piotrpMSFT Can project.json allow one to declare the attributes (under a runtime section), which are then converted to a file (e.g. app.exe.config of sorts) that is published with the app (for both compile and publish scenarios).
Isnt project.json analogous to a VS project that contains similar information?
True, project.json is analogous to csproj, but I should note that runtime information (GC type, etc.) isn't stored in csproj today, rather in an app.config file that gets copied to the output directory and renamed to app.exe.config ;).
I don't really mind hugely either way, but I'd kinda rather define this "runtime configuration" file if we need it and just make it a source file that gets copied as is (and renamed possibly) rather than transcribing between two (potentially different) formats.
It needs to be a structured format that needs to be documented for folks to take advantage of it. Lets wait to see @blackdwarf spec for it.
We may as well preserve the project.json at runtime instead of moving between formats
@davidfowl, I agree with the json. We used xml on desktop. For Jan, can we have a simple file that can be parsed easily by native host?
Sounds fine to have the simple file but there's no point transforming the json into this file. Just put that file in the root of your project and have compile copy it to the output folder as is
Given how this file is growing in complexity (with good reason), I'm leaning towards just saying there is one file, it contains all the dependencies (deps file) and config, and it is in a well-known format like JSON. It means we have to parse JSON in the native host, but at least then we aren't inventing some weird format that no-one else understands. Just like we used XML in the desktop framework config file (and everyone knows JSON is the new XML ;))
@blackdwarf, did you arrive at a plan for this? This might become important soon, because currently, SERVER_GC is by default ON for all platforms and if you want to turn it off you have to set an environment variable. People might get frustrated by the ElCap issue that @davidfowl was hitting recently in Mac development mode (https://github.com/dotnet/cli/issues/652) I also need enough time to get your proposed policy implemented, so I want to make sure this is getting your attention.
PS: If you want to chat, you know the office I sit in :smile:
@schellap was thinking about doing this this week. :) Will find you to chat! :)
OK, based on discussions we had yesterday here is a plan on what we should do.
We have two specific needs:
- Provide a set of configuration options for native compilation
- Provide a set of configuration options/knobs for runtime behavior of applications
Given the above, the suggestion is the following:
- For native compilation options we should have a new node in
project.jsonthat will contain these. - For runtime options, we should have a new file, let's call it
runtime.json, that contains the runtime knobs.
This solution nicely separates the domains of responsibility of each file; project.json is still responsible
for design-time options, while the new file, runtime.json is responsible for runtime configuration of the
application. This also means that we are not impacting performance, since runtime.json contains only the
knobs the app needs at runtime, so no parsing the entire PJ and a mess of things that are irrelevant.
The runtime.json needs to be available to the application on runtime. In order for this to happen, we
should reuse the content support that we already have. This means that the developer defines runtime.json
as content and we copy it over. Corehost knows where the file is, and reads it.
I don't think this model changes even for the shared runtime/fx model.
If everyone is a-ok with this plan, we need to define the schema of both the native compilation options
node in PJ and the entire runtime.json. @schellap and I will have a crack at that.
Oh, and I think we should go with JSON as the format just because, as @anurse said, it is the new XML. Also, because everything else in our toolset is also JSON, so no need to reinvent the wheel.
/cc @piotrpMSFT @gkhanna79 @anurse @davidfowl
For runtime options, we should have a new file, let's call it runtime.json, that contains the runtime knobs.
Ugh no. That'll be confusing with nuget's runtime.json. Everytime we refer to it we'll need to explain which one we're talking about.
app.config.json then? Similar to desktop?