DotNetApp: .NET application

DotNetAppR Documentation

.NET application

Description

Documentation for dotnet's internal 'DotNetApp' R6 class.

Methods

new(app_name, app_dir, language, packages)

Creates a new .NET console application in app_dir

add_package(package_name)

Adds NuGet package to the app

add_source(source_code, file_name = "Program")

Add source code to the app; note: the extension will be appended automatically based on the app's language

build(output_dir)

Builds app and outputs artifacts to output_dir

run(capture_output = TRUE)

Runs app and returns character output

Properties

language

The app's language (C# or F#, specified during creation)

path

Full path to the app's files

packages

NuGet package names, added with $add_package() method

source_files

Source file names, added with $add_source() method

source_code

Named list of source files' contents

Languages

When creating a new DotNetApp, it defaults to the programming language set in dotnet.language option, which is C# by default. This can be overridden by specifying language = "F#" when creating a new instance or by changing the default via options(dotnet.language = "F#"), to avoid having to specify it every time.

Packages

Packages can be added to the app after it was created by using add_package method. Packages can be added at create time by specifying them with the packages argument when calling $new().

To avoid having to add packages manually every time when creating a new app or if you have multiple chunks using the dotnet knitr engine and they all depend on the same set of packages, you can set a character vector of package names in the dotnet.packages option. Those packages will be added automatically to all newly created apps.

Debug mode

To facilitate development, the debug_mode_on flag in $new() can be used to suppress any dotnet commands from actually running. Instead, the command that would have run is printed to the console for the user to run manually in the shell of their choice.

debug_csharp_app <- dotnet:::DotNetApp$new(debug_mode_on = TRUE)
debug_csharp_app$run()

bearloga/dotnet documentation built on April 5, 2022, 5:33 p.m.