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.

Improve "new vs. legacy" project system detection

See original GitHub issue

Both the new and legacy project system’s have a file extension of csproj/vbproj. This means that when a project opened, we need to “sniff” as to whether it needs to open in the new or legacy project system. The existing detection is called out in https://github.com/dotnet/project-system/blob/master/docs/opening-with-new-project-system.md.

This has a pretty major flaw:

  • If you move the <TargetFramework> or <TargetFrameworks> elements into an import, we don’t recognize it as an SDK-project and it opens in legacy, which leads to a prompt similar to below.

image

This prompt occurs because the project file is missing “ToolsVersion” (now optional) which makes the legacy project system think that the project comes from VS 2008 or earlier.

We should improve the detection. The detection must be extremely quick. This will run for every csproj/vbproj. This rules out doing an evaluation to figure out if the project has a <TargetFramework> property somewhere else in its graph, evaluations take anywhere from 10ms to 100ms and currently (due to architecture) it’s extremely difficult to share this evaluation with the project system that ends up opening the project.

I propose, that we change the detection as follows.

In addition to the </TargetFramework> and </TargetFrameworks> detection[1], opt any project that is marked with an SDK, either at the project node, via the <Sdk /> or <Import Sdk=""/> constructs.

This means that following 5 projects will be opt’d into the new project system:

<Project Sdk="Microsoft.Net.Sdk">
...
</Project>
<Project Sdk="Microsoft.Net.Sdk.Web">
...
</Project>
<Project Sdk="MSBuild.Sdk.Extras">
...
</Project>
<Project>
    <Sdk Name="My.Custom.Sdk" Version="1.0.0" />
...
</Project>
<Project>
    <Import Project="Sdk.props" Sdk="Microsoft.NET.Sdk" />
...
</Project>

[1] This makes sure that those that imported the SDK in an import, but left <TargetFramework> or <TargetFrameworks> element to make sure it opened in CPS still continue to open in CPS.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:9
  • Comments:19 (14 by maintainers)

github_iconTop GitHub Comments

1reaction
Rabadash8820commented, Dec 9, 2019

@drewnoakes I just installed VS 16.4 and can confirm that importing TargetFramework from a Directory.Build.props file is working as advertised. Thanks again!

1reaction
ghostcommented, Nov 18, 2019

Excellent, thanks for the quick reply. I can wait for GA with the TargetFramework workaround. Keep up the good work y’all!

Read more comments on GitHub >

github_iconTop Results From Across the Web

The Right Way to Take Over a Legacy Project
Discover the most common challenges and misconceptions around legacy projects, and how our team worked through them.
Read more >
Is Every Enterprise Project a Legacy? | by Sasha Mathews
Legacy system or legacy code has become synonymous with bad systems that software engineers don't want to deal with. Legacy systems usually have...
Read more >
The Ship of Theseus to NOT rewrite a legacy system from ...
How to rewrite a legacy codebase ... The strategy is simple: Progressively delete the old code base, in favor of a new one....
Read more >
Five Things to Remember When Upgrading Your Legacy ...
Updating a legacy system is challenging. By choosing the right modernization strategy and teams you can easily cut down the legacy software ...
Read more >
What Is a Legacy System and What Are Legacy Applications?
A legacy system is any outdated computing system, hardware or software that is still in use. Legacy systems include computer hardware, software applications ......
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