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

Ensure built-in and imported targets are respected by the solution pr… #1590

Merged
merged 2 commits into from
Jan 20, 2017

Conversation

jeffkl
Copy link
Contributor

@jeffkl jeffkl commented Jan 19, 2017

…oject generator.

The goal is to take whatever target the user specified from the command-line and add it to the metaproj. However, we add targets and targets can be imported.

This change ensures that command-line targets are added last after everything else and they're only added if they don't already exist. This removes the need to know what built-in targets are there. If the user specifies /t:Clean, then it's still added as a built-in target and at the end when adding user specified targets it is ignored.

Another case is for projects. We add a targets like "Project_Name", "Project_Name:Clean" where the project name becomes a target. However we also add sub-targets which need to be respected. These are also now added before the user specified targets are added. If you specify /t:Project_Name:Clean, it won't be added to the project as a user specified target.

Unit test has been updated to hopefully test all built-in targets.

Closes #1587

…oject generator.

The goal is to take whatever target the user specified from the command-line and add it to the metaproj.  However, we add targets and targets can be imported.

This change ensures that command-line targets are added last after everything else and they're only added if they don't already exist.  This removes the need to know what built-in targets are there.  If the user specifies /t:Clean, then it's still added as a built-in target and at the end when adding user specified targets it is ignored.

Another case is for projects.  We add a targets like "Project_Name", "Project_Name:Clean" where the project name becomes a target.  However we also add sub-targets which need to be respected.  These are also now added before the user specified targets are added.  If you specify /t:Project_Name:Clean, it won't be added to the project as a user specified target.

Unit test has been updated to hopefully test all built-in targets.

Closes dotnet#1587
@jeffkl jeffkl added this to the Visual Studio 15 RTM milestone Jan 19, 2017
@@ -1942,6 +1917,13 @@ private void AddTraversalTargetForProject(ProjectInstance traversalProject, Proj
actualTargetName += ":" + targetToBuild;
}

// Don't add the target again. The user might have specified /t:Project:target which was already added but only this method knows about Project:Target so
// after coming up with that target name, it can check if it has already been added.
if (traversalProject.Targets.ContainsKey(actualTargetName))
Copy link
Member

Choose a reason for hiding this comment

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

Under what circumstances is this not redundant with the filtering you do here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If the project name contains a . or if you have two projects with the same name (like foo.csproj and foo.vbproj) then only this method knows what the final target names will be.

I tried to explain that in the comment. Should I reword it so it makes more sense?


Assert.Equal(1, instances.Length);

Assert.Equal(14, instances[0].TargetsCount);
Copy link
Member

Choose a reason for hiding this comment

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

Since it was a late regression, I'd love to see an explicit test of the after.sln.targets scenario. Would that be prohibitively hard to produce?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay I added a test for this.

Copy link
Contributor

@cdmihai cdmihai left a comment

Choose a reason for hiding this comment

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

LGTM. T'would be nice to have a new test like @rainersigwald suggested.

@rainersigwald rainersigwald changed the base branch from vs15-rc3 to vs15-rtw January 20, 2017 00:16
@rainersigwald
Copy link
Member

Retargeted to RTW.

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.

5 participants