-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
sln-add: Support for slnx #44570
base: main
Are you sure you want to change the base?
sln-add: Support for slnx #44570
Conversation
d397257
to
b6aa066
Compare
9f9f687
to
6e7f552
Compare
Refactor code Refactor code Add translations Fix typo Fix issues with --solution-folders Standarize error messages and tests Fix solution folder formatting Nit: Address pr comments
bf6d349
to
90f4248
Compare
@edvilme checkout the complete feedback. using solution.FindProject makes the regex usage irrelevant |
24c9885
to
a4a9f74
Compare
that will hopefully fix errors like |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here, const strings for expected sln results were moved to a folder under TestAssets, with their .slnx counterparts generated by dotnet sln migrate
.
Additional test cases were created for sln.
SlnFile
was removed from these tests as well
the identifier doesn't help because testmanager's GetTestDestinationDirectoryPath shortens the directory name to 24 characters and we end up having the same errors. short-term solution is #45130 which goes beyond _2 in the ci. long-term solution is to make GetTestDestinationDirectoryPath stateless and use Path.GetTempFileName without any hashing or ci specific complexity; right now there are tests like |
Yes, it pushed before I was able to see your pr, bit of a sync issue there... I like the idea on your PR as it allows us to have a greater variety of different names for different cases (of which there are many on this pr) |
getting closer! 👍 these tests are failing: sdk/test/dotnet-new.Tests/PostActionTests.cs Line 782 in e524077
sdk/test/dotnet-new.Tests/PostActionTests.cs Line 818 in e524077
sdk/test/dotnet-new.Tests/PostActionTests.cs Line 854 in e524077
test is adding |
Hii, thanks and thanks for your input. Yes, those tests are currently failing on several PRs and should be unrelated to the changes here. When they're fixed, I will update the branch :) |
can you point me to it?
main:
with 5 retries back and forth, those three tests 100% of the times fail with your branch locally and pass with main |
You're right. There were some other tests from templating failing, so I got them mixed up. The issue here is when adding projects from a different directory, e.g., |
…o edvilme-slnx-add
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm (one nit)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mostly just questions 🙂 Thanks for all your work to enable this!
PathUtility.EnsureAllPathsExist(arguments, CommonLocalizableStrings.CouldNotFindProjectOrDirectory, true); | ||
|
||
var fullProjectPaths = _arguments.Select(p => | ||
try |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: \n before this
(Also just anywhere you have }, I prefer a \n before the next thing with few exceptions)
AddProjectsToSolutionAsync(solutionFileFullPath, fullProjectPaths, CancellationToken.None).Wait(); | ||
return 0; | ||
} | ||
catch (GracefulException) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The other catch explicitly excludes this case, and this case just throws, so we can skip this block.
|
||
var currentDirString = $".{Path.DirectorySeparatorChar}"; | ||
if (projectFilePath.StartsWith(currentDirString)) | ||
ISolutionSerializer serializer = SlnCommandParser.GetSolutionSerializer(solutionFileFullPath); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this a new runtime concept? I don't see it in the SDK currently or in this PR, and a quick bing (google) search didn't reveal anything interesting. If so, should we put this behind #ifdefs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Which part are you refering to here?
ISolutionSerializer serializer = SlnCommandParser.GetSolutionSerializer(solutionFileFullPath); | ||
SolutionModel solution = await serializer.OpenAsync(solutionFileFullPath, cancellationToken); | ||
// set UTF8 BOM encoding for .sln | ||
if (serializer is ISolutionSerializer<SlnV12SerializerSettings> v12Serializer) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the significance of V12?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think the "v12" format ensures compatibility with Visual Studio 2013 and later versions. previous versions of vs might not understand solution files created in this schema unless explicitly backported. It has enhanced support for modern project types, including new sdk-style projects and multi-targeting and better integration with msbuild, with the solution file acting as a meta-structure over the projects it includes.
{ | ||
if (_inRoot) | ||
// Set default configurations and platforms for sln file | ||
foreach (var platform in new[]{ "Any CPU", "x64", "x86" }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought we supported ARM now? Not relevant here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yea platform can be arm/arm64 as well
sdk/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.RuntimeIdentifierInference.targets
Line 146 in 8f63ab4
<When Condition="$(RuntimeIdentifier.EndsWith('-arm64')) or $(RuntimeIdentifier.Contains('-arm64-'))"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, platform can be arm64 too, however this was added as to not break existing changes. In one of the comments I suggest maybe making this a constant so we can modify it easily in the future (?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is a drop-in replacement for what dotnet sln add
generates today. visual studio generates the similar file when you create a project with solution (it has no arm or arm64).
so far there is no issue showing that it has ever been a requirement from users but even if it is requirement it should be added as a new opt-in option on dotnet sln add
command so user can decide if they want to add more platforms
foreach (var solutionPlatform in solution.Platforms) | ||
{ | ||
var projectPlatform = projectInstancePlatforms.FirstOrDefault( | ||
x => x.Replace(" ", string.Empty) == solutionPlatform.Replace(" ", string.Empty), projectInstancePlatforms.FirstOrDefault("Any CPU")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: better name for 'x'?
} | ||
foreach (var solutionPlatform in solution.Platforms) | ||
{ | ||
var projectPlatform = projectInstancePlatforms.FirstOrDefault( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If there are multiple, we only care about the first?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, we currently have a test that checks if the first match is added
Contributes to #40913
This adds
dotnet sln add
support for .slnx files