Skip to content

Add Shell Execution Extensions to Context - #4

Merged
SimonDarksideJ merged 6 commits into
MonoGame:mainfrom
AristurtleDev:feature/context-extensions
Nov 28, 2026
Merged

SimonDarksideJ merged 6 commits into
MonoGame:mainfrom
AristurtleDev:feature/context-extensions

Conversation

@AristurtleDev

Copy link
Copy Markdown
Contributor

Adds extension methods for FrostingContext to help with executing shell commands per platform

Comment thread FrostingContextExtensions.cs Resolved
Comment thread FrostingContextExtensions.cs Resolved
Comment thread FrostingContextExtensions.cs Outdated
_processSettings.WorkingDirectory = path;
}

public static int ShellExecute(this FrostingContext context, string command, string environmentVariables = "")

@harry-cpp harry-cpp Apr 29, 2024 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pass env variables in a separate function SetShellEnvVariables(parms string[] env)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 23d2fc1

From our previous discussion, the export keyword is in fact required. Without it, the environment variables do not stay set if the command executes something that in turn executes something else. So the export is required for the entire run of the process.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Additionally, I was not able to find any decent way of doing space character escapes in the command. The problem comes in situations where you want to set an environment variable such as

context.SetShellEnvironmentVariables("CFLAGS", $"-w -arch arm64 -I{dependencyDir}/include");

The space escapes would need to be set for the path in the -I flag, however you would need to differentiate between what is a path and what isn't, such as the -w -arch arm64 part. Otherwise, you end up with a sanitized environment variable such as CFLAGS="-w\ -arch\ arm64\ -i/path/to\ some/directory/include;" which fails to run.

Open to suggestions on this if still needed

@harry-cpp harry-cpp Apr 30, 2024 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are supposed to set it to either:

CFLAGS=-w\ -arch\ arm64\ -i/path/to\ some/directory/include;

or

CFLAGS="-w -arch arm64 -i/path/to some/directory/include";

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Harry done in eacf3fa

@SimonDarksideJ

Copy link
Copy Markdown
Contributor

Any further update @AristurtleDev , seems there are merge conflicts now.
Any closer to this being ready @harry-cpp >?

@SimonDarksideJ
SimonDarksideJ merged commit b84e17c into MonoGame:main Nov 28, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants