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

Allow projects with no restore target to build under dotnet build #6430

Merged
merged 3 commits into from May 11, 2021

Conversation

Forgind
Copy link
Member

@Forgind Forgind commented May 7, 2021

Work item (Internal use): AB#1326205

Summary
We introduced a new error with #6312 when there is no restore target. Builds had previously failed mysteriously after Restore had failed (because it didn't exist) but not failed the whole build. We put it under a change wave in #6372, but we still decided to revisit it. Specifically, if customers don't intentionally request a restore, dotnet build will still implicitly add one. With that change, customers without a restore target will then fail. They may not have a valid restore target because they failed to resolve an SDK—a problem we should alert them to—but they also might not have needed it.

This change maintains the SDK resolution failure case but dispenses with the missing target failure case.

Customer Impact
Customers calling restore (including indirectly through dotnet build) see failures if there is no restore target, including when no sdk with a restore target is in use.

Regression?
Yes. Worked in 16.9, regressed in 16.10.0 because of #6312

Testing
Unit tests and tried a local repro that didn't work with the bootstrap version.

Risk
Low. Just removes a new error.

Copy link
Contributor

@jeffkl jeffkl left a comment

Choose a reason for hiding this comment

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

Thank you for taking care of this!

ref/Microsoft.Build/net/Microsoft.Build.cs Outdated Show resolved Hide resolved
/// Verifies a non-existent target doesn't fail restore as long as its not considered an entry target, in this case Restore.
/// </summary>
[Fact]
public void RestoreSkipsNonExistentNonEntryTargets()
Copy link
Contributor

Choose a reason for hiding this comment

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

This unit test is no longer applicable

/// Verifies restore will run InitialTargets.
/// </summary>
[Fact]
public void RestoreRunsInitialTargets()
Copy link
Contributor

Choose a reason for hiding this comment

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

Leave this one here just for good measure

Forgind added a commit to Forgind/msbuild that referenced this pull request May 7, 2021
Maximal subset of dotnet#6312 and dotnet#6372.

Also removes an unnecessary test per dotnet#6430 (comment)
documentation/wiki/ChangeWaves.md Show resolved Hide resolved
@@ -1785,8 +1785,7 @@ private List<ProjectRootElement> ExpandAndLoadImports(string directoryOfImportin

if (!sdkResult.Success)
{
// Ignore the missing import if IgnoreMissingImports is set unless FailOnUnresolvedSdk is also set
if (_loadSettings.HasFlag(ProjectLoadSettings.IgnoreMissingImports) && !_loadSettings.HasFlag(ProjectLoadSettings.FailOnUnresolvedSdk))
if (_loadSettings.HasFlag(ProjectLoadSettings.IgnoreMissingImports) && (!ChangeWaves.AreFeaturesEnabled(ChangeWaves.Wave17_0) || !_loadSettings.HasFlag(ProjectLoadSettings.FailOnUnresolvedSdk)))
Copy link
Member

Choose a reason for hiding this comment

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

I don't think I understand this. Why is it not wave 16.10, the one for the release this is targeting? What is this expression representing? Why not do this the way it was done in the prior commit and condition adding the new flag on the changewave?

Copy link
Member Author

Choose a reason for hiding this comment

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

Will change to 16.10. I can also retarget this to vs16.10, since it's currently at master.

I think making the change in either place should be equivalent. I thought this would be cleaner. If you don't like it, I can change to the other way, though.

Forgind added a commit to Forgind/msbuild that referenced this pull request May 7, 2021
Maximal subset of dotnet#6312 and dotnet#6372.

Also removes an unnecessary test per dotnet#6430 (comment)
@Forgind Forgind changed the base branch from main to vs16.10 May 10, 2021 15:42
@rainersigwald rainersigwald added this to the MSBuild 16.10 milestone May 10, 2021
@rainersigwald rainersigwald changed the title Fail on missing sdk only Allow projects with no restore target to build under dotnet build May 11, 2021
@rainersigwald rainersigwald merged commit 4718a4c into dotnet:vs16.10 May 11, 2021
@Forgind Forgind deleted the fail-on-missing-sdk-only branch May 11, 2021 18:07
JaynieBai pushed a commit that referenced this pull request Feb 8, 2023
)

Bumps Microsoft.CodeAnalysis.BannedApiAnalyzers from 3.3.3 to 3.3.4.

Release notes
Sourced from Microsoft.CodeAnalysis.BannedApiAnalyzers's releases.

v3.3.4
Release build of Roslyn-analyzers based on Microsoft.CodeAnalysis 3.3.1 NuGet packages. Works with VS 2019 16.9 or later.

Contains important functionality and performance bug fixes on top of v3.3.3 release
Commits
22ea642 Merge pull request #6436 from ViktorHofer/patch-1
9018071 Fix buildtransitive vs buildTransitive difference
afa5665 [main] Update dependencies from dotnet/arcade (#6423)
afee469 Merge pull request #6427 from mavasani/CodeAnalysisTreatWarningsAsErrors_Glob...
b858999 Merge pull request #6430 from dotnet/locfiles/be3abf9f-1f22-469b-b26d-7648587...
0cbc3c5 Localized file check-in by OneLocBuild Task: Build definition ID 830: Build I...
113dadc Merge pull request #6429 from dotnet/revert-6364-net7-tests
356147f Revert "Move tests to target .NET 7"
1d7244a Update documentation for CodeAnalysisTreatWarningsAsErrors implementation
6c028d3 Re-implement CodeAnalysisTreatWarningsAsErrors with globalconfig files
Additional commits viewable in compare view
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants