Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No longer work after upgrading 5.0.301 from 6.0.101 #1522

Closed
jimmy-vo-librestream opened this issue Feb 18, 2022 · 3 comments
Closed

No longer work after upgrading 5.0.301 from 6.0.101 #1522

jimmy-vo-librestream opened this issue Feb 18, 2022 · 3 comments

Comments

@jimmy-vo-librestream
Copy link

Here is my project structure:

- .config
- .husky
- src:
| - Project 1
| - Project 2
| - Project 3
| - Project 4
- package.json

Here is my lint-staged config in package.json

  "lint-staged": {
    "*.cs": [
      "dotnet format ./  --include"
    ]
  },

dotnet format was working fine with pre-commit with the sdk version 5.0.301
After I installed 6.0.101, it no longer working:

Unrecognized command or argument './'

'./' was not matched. Did you mean one of the following?
...

The work around I have tried:

  • specify global.json and force to use 5.0.301. This works out locally but I can't force other developers to install the same sdk version. Currently, we have to add this to gitignore, but it's inconvenient.
  • Specify a specific project folder in package.json as below. But this makes committing changes 4 times slower than usual :
  "lint-staged": {
    "*.cs": [
      "dotnet format ./src/Project 1  --include",
      "dotnet format ./src/Project 2  --include",
      "dotnet format ./src/Project 3  --include",
      "dotnet format ./src/Project 4  --include",
    ]
  },
@damienbod
Copy link

damienbod commented Mar 11, 2022

still broken with sdk 6.0.3

Unhandled exception: System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types.
Could not load file or assembly 'Microsoft.CodeAnalysis.CSharp, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. The system cannot find the file specified.
Could not load file or assembly 'Microsoft.CodeAnalysis, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. The system cannot find the file specified.
   at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module)
   at System.Reflection.Assembly.GetTypes()
   at Microsoft.CodeAnalysis.Tools.Analyzers.AnalyzerFinderHelpers.<>c.<LoadAnalyzersAndFixers>b__0_0(Assembly assembly)
   at System.Linq.Enumerable.SelectManySingleSelectorIterator`2.MoveNext()
   at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
   at System.Linq.Enumerable.OfTypeIterator[TResult](IEnumerable source)+MoveNext()
   at System.Collections.Generic.LargeArrayBuilder`1.AddRange(IEnumerable`1 items)
   at System.Collections.Generic.EnumerableHelpers.ToArray[T](IEnumerable`1 source)
   at System.Collections.Immutable.ImmutableArray.CreateRange[T](IEnumerable`1 items)
   at System.Collections.Immutable.ImmutableArray.ToImmutableArray[TSource](IEnumerable`1 items)
   at Microsoft.CodeAnalysis.Tools.Analyzers.AnalyzerFinderHelpers.LoadAnalyzersAndFixers(IEnumerable`1 assemblies)
   at Microsoft.CodeAnalysis.Tools.Analyzers.AnalyzerReferenceInformationProvider.GetAnalyzersAndFixers(Project project)
   at System.Collections.Immutable.ImmutableDictionary.<>c__DisplayClass9_0`3.<ToImmutableDictionary>b__0(TSource element)
   at System.Linq.Utilities.<>c__DisplayClass2_0`3.<CombineSelectors>b__0(TSource x)
   at System.Linq.Enumerable.SelectIListIterator`2.MoveNext()
   at System.Collections.Immutable.ImmutableDictionary`2.AddRange(IEnumerable`1 items, MutationInput origin, KeyCollisionBehavior collisionBehavior)
   at System.Collections.Immutable.ImmutableDictionary`2.AddRange(IEnumerable`1 pairs, Boolean avoidToHashMap)
   at System.Collections.Immutable.ImmutableDictionary`2.AddRange(IEnumerable`1 pairs)
   at System.Collections.Immutable.ImmutableDictionary.ToImmutableDictionary[TSource,TKey,TValue](IE

@si618
Copy link

si618 commented Mar 11, 2022

still broken with sdk 6.0.3

Noticed the same thing, however this workaround does the job until the issue is resolved.

@JoeRobich
Copy link
Member

There is a fix coming in the next .NET 6 SDK release. In the meantime you can install dotnet-format as a global tool to work around this issue (See #1519 (comment)). Closing this issue as duplicate of #1519

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants