Comments (12)
This means that the environment in which dotnet format is running in is configured such that it can't find where MSBuild is located. How did you install dotnet format
on the machine?
from format.
Lines 79 to 81 in 3684ac0
from format.
@nnpcYvIVl Has you issue been resolved or can you share any more details about your installation and how you are running dotnet-format? Thanks!
from format.
@jmarolf @JoeRobich Sorry for the delay.
MSBuild was installed with Build Tools for Visual Studio 2017 and works without issue.
I installed dotnet-format with this command
dotnet tool install -g dotnet-format
Then I copied the "%userprofile%.dotnet\tools" folder to "%ProgramFiles(x86)%\dotnet-format".
From the command line I ran a batch file containing this command
"C:\Program Files (x86)\dotnet-format\dotnet-format.exe" --dry-run --workspace "C:\Users\User\ClassLibrary1\ClassLibrary1.sln" 1> "C:\Users\User\output.txt" 2>&1
It worked as expected and this was the output
Formatting code files in workspace 'C:\Users\User\ClassLibrary1\ClassLibrary1.sln'.
Formatting code files in project 'ClassLibrary1'.
Formatted code file 'Class1.cs'.
Format complete.
When I create a scheduled task using the same credentials and pointing to the same batch file I get the failure with the stacktrace posted above.
from format.
@nnpcYvIVl dotnet-format uses the MSBuild from the .NET Core SDK. Does the user that the scheduled task runs as have .NET Core installed?
from format.
@JoeRobich Thanks for the clarification on the MSBuild version.
.NET Core is installed for that user, here is the output of a couple of commands:
dotnet --info
.NET Core SDK (reflecting any global.json):
Version: 2.2.203
Commit: e5bab63eca
Runtime Environment:
OS Name: Windows
OS Version: 6.3.9600
OS Platform: Windows
RID: win81-x64
Base Path: C:\Program Files\dotnet\sdk\2.2.203\
Host (useful for support):
Version: 2.2.4
Commit: f95848e524
.NET Core SDKs installed:
2.2.203 [C:\Program Files\dotnet\sdk]
.NET Core runtimes installed:
Microsoft.AspNetCore.All 2.2.4 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.2.4 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 2.2.4 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
To install additional .NET Core runtimes or SDKs:
https://aka.ms/dotnet-download
dotnet tool list -g
Package Id Version Commands
---------------------------------------------
dotnet-format 3.0.4 dotnet-format
from format.
@nnpcYvIVl Instead of moving dotnet-format out of the .dotnet/tools folder. Can you instead install dotnet-format as the user that the scheduled task runs as. I am not sure manually relocating dotnet global tools is supported.
from format.
Not directly related, but I received the same error when trying to run from a make file under msys2 (or cygwin). Here was my solution that I still want to try to improve. Basically I needed two additional paths in my search path: the install path %USERPROFILE%\.dotnet\tools
(see) and C:\Program Files\dotnet
DOTNET_TOOLS = $(shell cygpath $(USERPROFILE)/.dotnet/tools)
format-check:
PATH=$(PATH):/c/Program\ Files/dotnet:$(DOTNET_TOOLS) dotnet-format --check -v diagnostic -w $(SOLUTION)
from format.
If we want running from a non-sdk environment to work, I would recommend allowing users to specify an explicit path to msbuild.
from format.
dotnet-format is a dotnet tool designed to be installed and run by the dotnet CLI. We won't support other installation method at this time. dotnet CLI local tools are a newer concept that may work well for this scenario.
from format.
I ran into this issue as well, probably due to another installation method. The dotnet core SDK was missing, and the error message InvalidOperationException: Sequence contains no elements
does not really give any clue of the real error.
Can this error message be improved to say something along the lines:
Could not find MSBuild, make sure .NET Core SDK is installed
from format.
@Loffe Thanks for the suggestion. It'll be in the next release.
from format.
Related Issues (20)
- Please clarify if this tool is actively supported / worked on HOT 2
- Can I use dotnet format to just generate report and not make the changes to the file. HOT 2
- Issue: Limited Scope for Running the Tool on Changed Files in Pull Requests HOT 1
- running dotnet format on my unity project takes over an hour HOT 2
- .net 8.0.2 Blazor `_imports.razor` & using `IDE0005` HOT 4
- Not detect IDE0290. HOT 1
- IDE0051 format issues with Razor code behind files with SDK 8.0.200 HOT 4
- Questions around Contributing to the Repo HOT 5
- dotnet format is now part of the SDK repo HOT 1
- Wrong indentation when using primary constructor
- Simplify interpolation (IDE0071) - false positive with Enum and FormattableString
- CA1067 on C# record implementing a VB.NET interface
- Does not adhere to language set in `DOTNET_CLI_UI_LANGUAGE`
- Line wrapping and indentation of Collection Literals
- Error Changing document properties is not supported HOT 2
- CS0534 validation adding wrong code. HOT 1
- pre-commit hook fails: no compatible SDK was found HOT 1
- Feature Request: Support for Excluding Specific Subcommands with --skip in dotnet format
- Can't suppress WHITESPACE warnings HOT 2
- [NETSDKE2E][Regression]Failed to run format project with "test.cmd" command. HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from format.