Skip to content

Fix LangVersion for C# projects#33868

Merged
stephentoub merged 1 commit intodotnet:masterfrom
stephentoub:langpreview
Mar 21, 2020
Merged

Fix LangVersion for C# projects#33868
stephentoub merged 1 commit intodotnet:masterfrom
stephentoub:langpreview

Conversation

@stephentoub
Copy link
Member

For some reason I've not yet determined, the Language==C# condition is failing, resulting in us using latest rather than preview for building all of our C# projects. Since all of our projects are C# except for a single VB project, I've just defaulted to preview unconditionally and overrode it in that single .vbproj (since VB doesn't allow "preview").

cc: @ViktorHofer

@ViktorHofer
Copy link
Member

The msbuild <Language> property is defined in the language specific targets file, ie for C#: https://github.com/microsoft/msbuild/blob/3453beee039fb6f5ccc54ac783ebeced31fec472/src/Tasks/Microsoft.CSharp.CurrentVersion.targets#L39. This means that the property isn't available for comparison in Directory.Build.props. This was always broken and instead should have been placed in Directory.Build.targets.

@stephentoub
Copy link
Member Author

This was always broken and instead should have been placed in Directory.Build.targets.

So the right fix is just to move the existing two lines into Directory.Build.targets instead?

@ViktorHofer
Copy link
Member

Yes :)

@stephentoub
Copy link
Member Author

I'll update it. But in the meantime, @ViktorHofer, what's going on here?

  Microsoft.DotNet.ToolPackage.ResolverCacheInconsistentException: more than one row for coverlet.console-1.7.0-net5.0-any-coverlet
     at Microsoft.DotNet.ToolPackage.LocalToolsResolverCache.TryGetMatchingRestoredCommand(RestoredCommandIdentifier restoredCommandIdentifier, CacheRow[] cacheTable, RestoredCommand& restoredCommandList)
     at Microsoft.DotNet.ToolPackage.LocalToolsResolverCache.TryLoad(RestoredCommandIdentifier restoredCommandIdentifier, RestoredCommand& restoredCommand)
     at Microsoft.DotNet.Tools.Tool.Restore.ToolRestoreCommand.PackageHasBeenRestored(ToolManifestPackage package, String targetFramework)
     at Microsoft.DotNet.Tools.Tool.Restore.ToolRestoreCommand.InstallPackages(ToolManifestPackage package, Nullable`1 configFile)
     at Microsoft.DotNet.Tools.Tool.Restore.ToolRestoreCommand.<>c__DisplayClass11_0.<Execute>b__0(ToolManifestPackage package)
     at System.Linq.Enumerable.SelectArrayIterator`2.MoveNext()
     at System.Linq.ParallelEnumerable.ToList[TSource](ParallelQuery`1 source)
     at System.Linq.ParallelEnumerable.ToArray[TSource](ParallelQuery`1 source)
     at Microsoft.DotNet.Tools.Tool.Restore.ToolRestoreCommand.Execute()
     at Microsoft.DotNet.Cli.DotNetTopLevelCommandBase.RunCommand(String[] args)
     at Microsoft.DotNet.Tools.Tool.ToolCommand.Run(String[] args)
     at Microsoft.DotNet.Cli.Program.ProcessArgs(String[] args, ITelemetry telemetryClient)
     at Microsoft.DotNet.Cli.Program.Main(String[] args)

@ViktorHofer
Copy link
Member

ViktorHofer commented Mar 20, 2020

#33837. I'm working on a fix (workaround) right now.

@stephentoub
Copy link
Member Author

stephentoub commented Mar 20, 2020

As a benefit of that error / callstack, I noticed dotnet/sdk#10937 😄

@ViktorHofer
Copy link
Member

Nice!

@stephentoub
Copy link
Member Author

@ViktorHofer, I'm undoing your suggested change; it breaks everything 😦

Copy link
Member

@ViktorHofer ViktorHofer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK sorry :(

@stephentoub
Copy link
Member Author

No worries :)

@stephentoub stephentoub merged commit 741691c into dotnet:master Mar 21, 2020
@stephentoub stephentoub deleted the langpreview branch March 21, 2020 15:03
@ghost ghost locked as resolved and limited conversation to collaborators Dec 10, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants