Set project arguments for Release configuration, as well as "Publish to Folder" configurations

Hello everyone,

my goal is to specify project arguments (arguments that will be passed to the `Main` method), not only for the Debug configuration (as explained in https://www.jetbrains.com/help/rider/Run_Debug_Configuration.html), but for the Release configuration, meaning the actual build in the end with the binary files, as well. Now I also have certain special build configurations, targeting different operating systems and architectures (win-x64, osx-x64, linux-x64 etc.), where I also want to pass those arguments for the final builds. 

When I edit the configurations with the “Release” configuration selected, there is no option for the project arguments. How can I specify those arguments nonetheless for my final builds?

Thank you very much already in advance!

Rider 2023.2.3
.NET 7.0 (C# 11.0)

0
3 comments

It seems that you need to handle command-line arguments directly in your program.

Below is an example of a simple Console App designed to receive two arguments. To simplify the debugging process, you can specify the program arguments in the Debug profile as shown below:

For the published version of your application, you will need to pass the arguments when executing the program, as illustrated below. This is the standard way command-line arguments are handled:

If the arguments you need are not dynamic – that is, if they are always the same – you could choose to hard-code them directly into your program.

0

Hello Tao Sun ,

thank you very much for your response. I need to excuse myself for the late answer, but I really couldn't answer until now. Is there a way to pass program arguments otherwise, if I just select a Run configuration (for different platforms) and click the “Run” button to let it run the configuration and create the necessary binary files for the final build?

0

If you prefer to add the configuration in CLI interface, you may refer to the dotnet build CLI tool usage, which allow you specify the build configuration and pass it with arguments. 

Then you can create a new Run/Debug Configuration in Rider and use the Shell Script type. Then you can add the created configuration in the Before launch list of any existing Run profiles. 

0

Please sign in to leave a comment.