Can't pass msbuild params in `dotnet run`
See original GitHub issueSteps to reproduce
I can’t pass msbuild params from dotnet run
command. I can use
dotnet restore /p:PARAM=1 solution.sln
dotnet build /p:PARAM=1 solution.sln
but can’t write dotnet run /p:PARAM=1 soluition.sln
because these params are not passed to msbuild.
Expected behavior
msbuild params are passed to msbuild.
Actual behavior
msbuild params are not passed to msbuild.
Environment data
dotnet --info
output:
.NET Command Line Tools (2.0.0-preview1-005977)
Product Information: Version: 2.0.0-preview1-005977 Commit SHA-1 hash: 414cab8a0b
Runtime Environment: OS Name: ubuntu OS Version: 16.04 OS Platform: Linux RID: ubuntu.16.04-x64 Base Path: /usr/share/dotnet/sdk/2.0.0-preview1-005977/
Microsoft .NET Core Shared Framework Host
Version : 2.0.0-preview1-002111-00 Build : 1ff021936263d492539399688f46fd3827169983
Issue Analytics
- State:
- Created 6 years ago
- Reactions:19
- Comments:17 (2 by maintainers)
Top Results From Across the Web
Unable to pass -p argument to .NET app when using dotnet ...
I am trying to pass a command line argument -p to my .NET Core app using dotnet run : dotnet run -p /Users/user/Pictures...
Read more >dotnet build command - .NET CLI
The dotnet build command builds a project and all of its dependencies.
Read more >dotnet run command - .NET CLI
Delimits arguments to dotnet run from arguments for the application being run. All arguments after this delimiter are passed to the ...
Read more >dotnet publish command - .NET CLI
Any parameters passed to dotnet publish are passed to MSBuild. The -c and -o parameters map to MSBuild's Configuration and PublishDir ...
Read more >MSBuild reference for .NET SDK projects
Reference for the MSBuild properties and items that are understood by the .NET SDK.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
What’s the priority of this?
For consistency, if
dotnet run
will automatically kick off adotnet build
equivalent, then it ought to support passing the parametersdotnet build
can accept.I don’t think it’s entirely accurate to say that “dotnet run don’t have build involved other than to ensure the project is built already.” Lets say you had a msbuild project parameter that was necessary for a build to complete successfully, for example a relative path to a referenced project (probably not a best practice, but just a contrived example):
This builds fine with
dotnet build /p:PathToDep=../../my-dep-folder
and running the build binary withdotnet bin/Debug/Example.dll
also works fine, but there is no way to run this withdotnet run
without modifying the csproj. Whendotnet run
is invoked without the parameter I get a bunch of missing reference errors andThe build failed. Please fix the build errors and run again.
Also, regarding confusing argument passing there is already precedence for this because
dotnet run
accepts configuration and framework options (i.e. Debug vs Release). When it is necessary to disambiguate between options passed todotnet run
vs options passed to the project being run the double hyphen is used (from the dotnet run usage:dotnet run [options] [[--] <additional arguments>...]]
), for example:dotnet run -c Release -- -c "look my command takes dash c too"
I think this issue should be reopened.