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

Delegate parsing of targetFramework to dotnet CLI #3604

Open
wants to merge 2 commits into
base: v4.x
Choose a base branch
from

Conversation

gukoff
Copy link

@gukoff gukoff commented Feb 21, 2024

Issue describing the changes in this PR

Instead of parsing the .csproj file, determine the target framework by calling dotnet build -getproperty:TargetFramework.

It "works on my machine" (OSX, dotnet 8.0.201). I'm not aware if this solution has portability issues.

resolves #3565

Alternatives considered

I tried using new Project(path) instead of ProjectRootElement.Open(path) in hopes that new Project would find and import any external properties.

It didn't run. My .csproj file starts with <Project Sdk="Microsoft.NET.Sdk">, and calling new Project(csproj_content) throws exception The SDK 'Microsoft.NET.Sdk' specified could not be found.

Pull request checklist

  • My changes do not require documentation changes
    • Otherwise: Documentation issue linked to PR
  • [?] My changes do not need to be backported to a previous version
    • Otherwise: Backport tracked by issue/PR #issue_or_pr
  • I have added all required tests (Unit tests, E2E tests)

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

Successfully merging this pull request may close these issues.

NullReferenceException when TargetFramework is only specified in Directory.Build.props
1 participant