question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can't pass msbuild params in `dotnet run`

See original GitHub issue

Steps 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:open
  • Created 6 years ago
  • Reactions:19
  • Comments:17 (2 by maintainers)

github_iconTop GitHub Comments

8reactions
SidShetyecommented, Mar 20, 2020

What’s the priority of this?

For consistency, if dotnet run will automatically kick off a dotnet build equivalent, then it ought to support passing the parameters dotnet build can accept.

8reactions
sflankercommented, Oct 11, 2017

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):

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>netcoreapp1.1</TargetFramework>
    <AssemblyName>Example</AssemblyName>
    <OutputType>Exe</OutputType>
    <PackageId>Example</PackageId>
    <PackageTargetFallback>$(PackageTargetFallback);dnxcore50</PackageTargetFallback>
    <RuntimeFrameworkVersion>1.1.1</RuntimeFrameworkVersion>
  </PropertyGroup>

  <ItemGroup>
    <ProjectReference Include="$(PathToDep)/MyDependency.csproj" />
  </ItemGroup>

</Project>

This builds fine with dotnet build /p:PathToDep=../../my-dep-folder and running the build binary with dotnet bin/Debug/Example.dll also works fine, but there is no way to run this with dotnet run without modifying the csproj. When dotnet run is invoked without the parameter I get a bunch of missing reference errors and The 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 to dotnet 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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found