Thinkmine.NetX 1.0.17-preview

This is a prerelease version of Thinkmine.NetX.
dotnet add package Thinkmine.NetX --version 1.0.17-preview
                    
NuGet\Install-Package Thinkmine.NetX -Version 1.0.17-preview
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Thinkmine.NetX" Version="1.0.17-preview" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Thinkmine.NetX" Version="1.0.17-preview" />
                    
Directory.Packages.props
<PackageReference Include="Thinkmine.NetX" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Thinkmine.NetX --version 1.0.17-preview
                    
#r "nuget: Thinkmine.NetX, 1.0.17-preview"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Thinkmine.NetX@1.0.17-preview
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Thinkmine.NetX&version=1.0.17-preview&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Thinkmine.NetX&version=1.0.17-preview&prerelease
                    
Install as a Cake Tool

NetX

Release Notes Version Preview 1

This is a preview version of NetX focused on exploring functionality, usage scenarios, and feasibility. While all commands have been tested, all error conditions have not been encountered.

1.0.12-preview Changes
  • Added current_user
  • Added set_env for setting environment variables
  • Added exit for terminating the underlying process
1.0.3-preview Changes
  • Added support for Linux and OSX to exec
  • Added environment_variables
  • Added ```prompt(<text>)``
1.0.1-preview Changes
  • Added commandline
  • Added environment_variables
  • Added prompt(<text>)

Why netx

With the release of .NET 10 comes a powerful new feature to C#, dotnet run file. This capability in the new .NET build toolchain lets us run C# files directly from the dotnet run command. This means that we can easily execute functionality, using C#, in a manner very similar to writing scripts. To find out more about this feature here: https://devblogs.microsoft.com/dotnet/announcing-dotnet-run-app/

Of course there are still a number of differences, as C# even though extremely powerful is quite verbose in comparison to the needs of a script. This is obviously because it is designed primarily to be a language for building applications.

How it works

With the netx nuget and additional toolkit we make it easy for you to execute the most common script tasks by exposing those capabilities to you in a manner that can be easily leveraged for automation and general purpose scripting. netx offers the best of both worlds as you can seamlessly switch between top-down scripts and more sophisticated coding all in the same document.

Here is what a sample netx script looks like. Assuming this file was called dostuff.cs you can run this code and execute this functionality dotnet run dostuff.cs

#:package Thinkmine.NetX@1.0.13-preview
using static netx;

exec("dir");
exec("echo hello");
pwd();
cd("../../..");
rename("test.txt", "helloworld.txt");
list();
copy("bin", "test");
list();
pwd();
copy("program.cs", "c:/temp", true, "hello.cs");
pack("c:/temp", "temp.zip");
list();
unpack("temp.zip", "destination");
delete("temp.zip");
delete("destination");
delete("test");

Using netx you can add high level concepts like loops, function calls, referencing libraries, and much more to your scripting experience. We can, for instance, apply some conditional logic to our script from above as follows:

var passcode = prompt("What is your passcode");
if (passcode == "netx")
{
    exec("dir");
    exec("echo hello");
    pwd();
    cd("../../..");
    rename("test.txt", "helloworld.txt");
    list();
    copy("bin", "test");
    list();
    pwd();
    copy("program.cs", "c:/temp", "hello.cs");
    pack("c:/temp", "temp.zip");
    list();
    unpack("temp.zip", "destination");
    delete("temp.zip");
    delete("destination");
    delete("test");


    var v = http_get("http://www.google.com");
    print(v);

    var v2 = http_post("http://www.google.com", new
    {
        Name = "John",
        Age = 33,
    });
    print(v2);

    rename("helloworld.txt", "test.txt");
}
else
{
    print("You can't do this", "white", "red");
}

Now when the script runs the user is prompted to enter a passcode that we then check to see it's validity. Based on that we either execute the normal path or let the user know it can't be done.

Accessing command line arguments

To access command line arguments use the commandline global object. This object returns a string array of all the arguments passed into the program at run time. In the example below we use this object to detect whether any command line arguments have been sent in and print out the first argument if true.

print(commandline.Length.ToString());
if (commandline.Length > 0)
    print($"Command Line: {commandline[0]}");

Accessing environment variables

To access environment variables use the environment_variables global object. This object returns a string based name value dictionary of all global list of environment variables in scope during the exection of the program.

foreach (var item in environment_variables)
{
    print($"{item.Key}={item.Value}");
}

Calling Functions

We can even take it a bit further with the ability to make function calls.

var passcode = prompt("What is your passcode");
if (Validate(passcode))
{
    //normal flow
}
else
{
    print("You can't do this", "white", "red");
}


bool Validate(string passcode)
{
    if(passcode == "netx")
    return true;

    return false;
}

Basic commands

netx currently has 20 commands you can perform with it. The table below provides instructions on what they are and how to use them.

Command Sample Description
pwd pwd() Prints the current working directory to the console.
cd cd(<folder name>) Changes the current working directory to the one specified in the argument
list list() Lists all contents in the current folder
copy copy(<source>,<destination>) Copies a file or folder from source to destination
delete delete Deletes a file or folder
pack pack(<folder>,<zip file>) Zips a folder
unpack unpack(<file>,<folder>) Unzips a zip file to a folder
print print(<text>) Prints the specified text to the console
run run(<executable>) Runs an executable. The file must be in the current working folder or in the global path
exec exec(<command>) Executes a console command as if it was typed in and run directly in the console. This can be used do "ls", "dir", etc.
http_get http_get(<url>) Makes an HTTP GET call to the endpoint provided
http_post http_post(<url>,{object}) Makes an HTTP POS call to the endpoint provided, passing in an object as the payload. The object will be converted to json before being sent.
json json(<text>) Converts a string to a json object.
xml xml(<text>) Converts a string to an xml document.
commandline commandline Gets the command line that was passed into the script when it was run
environment_variables environment_variables Gets a string based name/value dictionary of all the enviroment variables in scope.
current_directory current_directory Gets the current directory as a string value
current_user current_user Gets the current user on which the script is running
exit exit Exits the process with an error code
set_env set_env Sets an environment variable
Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.17-preview 171 11/24/2025
1.0.16-preview 151 11/24/2025
1.0.15-preview 163 11/24/2025
1.0.14-preview 149 11/24/2025
1.0.12-preview 155 11/24/2025
1.0.11-preview 160 11/24/2025