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.

Support for piping the output of `dotnet sln list`

See original GitHub issue

I would like to use dotnet sln list in a script to automate some actions on projects. Unfortunately, the output of dotnet sln list is not suitable for piping into a script variable because it contains extraneous information.

Steps to reproduce

# powershell
$projectFiles = dotnet sln list
# bash
project_files=$(dotnet sln list)

Expected behavior

dotnet sln list should only produce output that lists the files, or support a flag like dotnet sln list --porcelain which suppresses the other info that breaks scripting.

Actual behavior

The first two lines of output are always irrelevant, and one first use, the output contains a welcome message that cannot be suppressed.

$ dotnet sln list

Welcome to .NET Core!
---------------------
Learn more about .NET Core: https://aka.ms/dotnet-docs
Use 'dotnet --help' to see available commands or visit: https://aka.ms/dotnet-cli-docs

Telemetry
---------
The .NET Core tools collect usage data in order to help us improve your experience. The data is anonymous. It is collected by Microsoft and shared with the community. You can opt-out of telemetry by setting the DOTNET_CLI_TELEMETRY_OPTOUT environment variable to '1' or 'true' using your favorite shell.

Read more about .NET Core CLI Tools telemetry: https://aka.ms/dotnet-cli-telemetry
Project(s)
----------
Abstractions/src/Microsoft.AspNetCore.DataProtection.Abstractions.csproj
Abstractions/test/Microsoft.AspNetCore.DataProtection.Abstractions.Tests.csproj
AzureKeyVault/src/Microsoft.AspNetCore.DataProtection.AzureKeyVault.csproj

Environment data

dotnet --info output:

.NET Core SDK (reflecting any global.json):
 Version:   3.0.100-preview-010184
 Commit:    c57bde4593

Runtime Environment:
 OS Name:     Mac OS X
 OS Version:  10.14
 OS Platform: Darwin
 RID:         osx.10.14-x64
 Base Path:   /Users/namc/src/aspnet/AspNetCore/.dotnet/sdk/3.0.100-preview-010184/

Host (useful for support):
  Version: 3.0.0-preview3-27414-8
  Commit:  2c740c0ea8

.NET Core SDKs installed:
  3.0.100-preview-010184 [/Users/namc/src/aspnet/AspNetCore/.dotnet/sdk]

.NET Core runtimes installed:
  Microsoft.AspNetCore.App 3.0.0-preview-19075-0444 [/Users/namc/src/aspnet/AspNetCore/.dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 2.2.1 [/Users/namc/src/aspnet/AspNetCore/.dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.0.0-preview-27324-5 [/Users/namc/src/aspnet/AspNetCore/.dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.0.0-preview3-27414-8 [/Users/namc/src/aspnet/AspNetCore/.dotnet/shared/Microsoft.NETCore.App]

To install additional .NET Core runtimes or SDKs:
  https://aka.ms/dotnet-download

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:6
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

4reactions
walkermundocommented, May 3, 2019

I too would like an option to the dotnet sln <SLN_FILE> list command to suppress the first two lines. It would be much cleaner to know that all output is usable and to not special case ignoring certain lines.

1reaction
woutervanvlietcommented, May 11, 2020

To remove the first two lines of output, you can use this solution: https://stackoverflow.com/a/24542679/803283

dotnet sln list | sed 1,2d

Or, if you’re unsure about how the output might change in the future:

dotnet sln ./build.sln list | grep -E \.csproj$
Read more comments on GitHub >

github_iconTop Results From Across the Web

dotnet sln command - .NET CLI
The dotnet-sln command provides a convenient option to add, remove, and list projects in a solution file.
Read more >
MSBuild reference for .NET SDK projects
Reference for the MSBuild properties and items that are understood by the .NET SDK.
Read more >
The "--output" option isn't supported when building a solution
I cannot see how to disable this option, below if the workflow file: name: Build and deploy ASP.Net Core app to ...
Read more >
Per-project output directory with dotnet build (Azure DevOps)
What I'd like is for there to be a proj1 and proj2 subdirectory created under publish_output and the artifacts from the projects placed ......
Read more >
.NET SDK Support
The following plugin provides functionality available through Pipeline-compatible steps. Read more about how to integrate steps into your Pipeline in the Steps ...
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