import os import sys def usage(): print("\nUsage: vs_add_launch_config.py optional(debug|release)\n") sys.exit(1) # Check if the right number of arguments are provided if len(sys.argv) < 3: usage() contents = ''' $(ProjectDir)..\..\..\game\%EXECUTABLE%.exe +developer 2 -dev $(ProjectDir)..\..\..\game WindowsLocalDebugger ''' exe = sys.argv[2] config = "debugoptimized" if len(sys.argv) > 3: config_arg = sys.argv[3] if config_arg != "debug": config = config_arg if config != "debugoptimized" and config != "release": print(f"\nInvalid build config specified: {config}") usage() contents = contents.replace('%BUILD_CONFIG%', config) contents = contents.replace('%EXECUTABLE%', exe) proj = sys.argv[1] # project comes from command-line argument vs_project_path = (f"build-{config}-sln/{proj}") target_filename = vs_project_path + ".user" # Write text to the file with open(target_filename, 'w') as file: file.write(contents)