Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can .NET CORE CLI - load arguments from file?

I am using .net cli 2.0.3 and I was wondering if it is possible to load my arguments from file i.e.

dotnet publish -args somefile

Where somefile will contain the arguments which the certain command accepts. For example, while publishing I want to have predefined path\project.csproj -c Release -o "outputpath"

I know that there isn't that kind of command in the sdk, but is there a way that I can achieve it ?

Best regards!

like image 408
Ivan Ruski Avatar asked Jun 12 '26 05:06

Ivan Ruski


1 Answers

While the CLI itself doesn't have a mechanism to load response files, it calls out to MSBuild which does support both specified response files and the following automatic response files:

  1. MSBuild.rsp next to the project / solution file to build
  2. Directory.Build.rsp in the hierarchy at or above the project / solution file to build

While you cannot specify CLI arguments, you can specify their equivalent MSBuild arguments.

For example you can create a release.rsp next to your solution file that specifies:

-p:Configuration=Release
-p:OutputPath=..\rel-out\
-p:PublishDir=..\pub-out\

Which you could use to call

dotnet publish test\project.csproj @release.rsp

If the same file was named Directory.Build.rsp, it would have been applied automatically. If would also have been applied autoamatically if it was named MSbuild.rsp and put it next to the csproj file.

like image 50
Martin Ullrich Avatar answered Jun 13 '26 19:06

Martin Ullrich



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!