Noel
Noel

Reputation: 5389

dotnet core build and json files created

If I have the following:

using log4net;
using log4net.Config;
using System;
using System.IO;
using System.Reflection;

namespace CoreTestLog4Net
{
    class Program
    {
        static void Main(string[] args)
        {
            var logRepository = LogManager.GetRepository(Assembly.GetEntryAssembly());
            XmlConfigurator.Configure(logRepository, new FileInfo("log4net.config"));

            var log = log4net.LogManager.GetLogger(typeof(Program));

            log.Info("test");



            Console.WriteLine("Hello ld!");
            Console.Read();
        }
    }
}

and I do the following in powershell simulating what would be done on a build server to package up an application:

`dotnet publish --output test

And I do ls .\CoreTestLog4Net\test I get this:

   Mode                LastWriteTime         Length Name
----                -------------         ------ ----
-a----       09/01/2018     18:24           3584 ClassLibraryA.dll
-a----       09/01/2018     18:24            244 ClassLibraryA.pdb
-a----       09/01/2018     18:51          55755 CoreTestLog4Net.deps.json
-a----       09/01/2018     18:24           5120 CoreTestLog4Net.dll
-a----       09/01/2018     18:24            588 CoreTestLog4Net.pdb
-a----       09/01/2018     18:51            154 CoreTestLog4Net.runtimeconfig.json
-a----       09/01/2018     13:28            447 log4net.config
-a----       08/03/2017     19:26         221184 log4net.dll

Then I do dotnet .\CoreTestLog4Net\test3\CoreTestLog4Net.dll to run the application.

My question is what are the two json files about?

If I delete them I get an error

Do they have to be deployed as part of the deployment when deploying to another machine?

Upvotes: 0

Views: 389

Answers (1)

Martin Ullrich
Martin Ullrich

Reputation: 100751

The json files are important and need to be included when deploying because:

  • .runtimeconfig.json tells the host (e.g. dotnet.exe) which framework+version to run the app with. E.g. if you have .NET Core 1.1 and 2.0 installed side-by-side, this file decides which one to use. Additionally, it contains flags to configure runtime and host settings, e.g. garbage collection settings.
  • .deps.json contains information about referenced packages and assemblies. .NET Core applications can reference assemblies from a package cache so your build doesn't need to copy all DLLs coming from NuGet packages to the output folder. The output of dotnet publish however will contain all files necessary for distribution. It is also used to resolve assets of the ASP.NET Core Runtime Store that are not added to publish outputs by default since they should be present on the target server.

Upvotes: 1

Related Questions