runtime: System.IO.FileSystem.AccessControl project has problems loading in Visual Studio
- I synced my local main branch to the latest bits.
- I successfully built everything successfully using:
build.cmd clr+libs+libs.pretest -rc release - Also successfully built and executed the unit tests in IO.FileSystem.AccessControl:
cd src/libraries/System.IO.FileSystem.AccessControl/tests dotnet build /t:Test - But when I open the FileSystem.AccessControl.sln file, all the types that exist both in
net461-windowsandnet6.0-windows, show the following error message and red squiggle:The type 'FileSystemRights' exists in both 'System.IO.FileSystem.AccessControl, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' and 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' System.IO.FileSystem.AccessControl.Tests (net461-windows)The call is ambiguous between the following methods or properties: 'FileSystemAclExtensions.CreateDirectory(DirectorySecurity, string)' and 'FileSystemAclExtensions.CreateDirectory(DirectorySecurity, string)' System.IO.FileSystem.AccessControl.Tests (net6.0-windows)Ambiguity between 'FileSystemAccessRule.FileSystemRights' and 'FileSystemAccessRule.FileSystemRights' System.IO.FileSystem.AccessControl.Tests (net6.0-windows)MSB4018 The "ResolvePackageDependencies" task failed unexpectedly. System.ArgumentException: An item with the same key has already been added. at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource) at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add) at System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement](IEnumerable`1 source, Func`2 keySelector, Func`2 elementSelector, IEqualityComparer`1 comparer) at Microsoft.NET.Build.Tasks.ResolvePackageDependencies.ExecuteCore() at Microsoft.NET.Build.Tasks.TaskBase.Execute() at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute() at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext() System.Security.Principal.Windows (src\System.Security.Principal.Windows) C:\Program Files\dotnet\sdk\5.0.102\Sdks\Microsoft.NET.Sdk\targets\Microsoft.PackageDependencyResolution.targets 186
These errors make it very difficult to work with this assembly:
- I can’t go to a type definition using F12.
- I can’t get intellisense to pop up.
- I cannot build directly from VS (I have to do it from the command line).
- I can’t run unit tests from VS (I have to attach VS to a command line execution).
Any help would be greatly appreciated. Let me know if you’d like me to show you a live repro.
cc @Anipik
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 15 (15 by maintainers)
So the building errors no longer seem to reproduce in the latest, but the intellisense errors still repro.
I debugged the design time build and found the following in the
$(NetCoreAppCurrent)-windowsbinlog:This implies a problem with evaluation. GeneratePlatformNotSupportedAssemblyMessage should not be set for Windows. It looks like this is due to ordering, we cannot use
TargetFramework-derived properties at all in the project file, we can only useTargetFrameworkitself.The reason this doesn’t reproduce on commandline build is due to TargetFramework being passed as a global property in this case.
Essentially the cause is the same as here: https://github.com/dotnet/runtime/issues/33427#issuecomment-597634844
I was able to workaround this by changing the conditions in the project file to use TargetFramework instead of TargetsWindows. I wonder if we should do this across the repo.