You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Let's say we have a solution SA with project PA that builds package SA.PA, and solution SB with projects PA and PB. Project PB uses a package SA.PA. Running switch-to-projects on SB throws an exception in this case. PA (from SA) is actually added to SB after that but the PackageReference to SA.PA in PB is not replaced.
Exception:
Microsoft.Build.Exceptions.InvalidProjectFileException: The solution file has two projects named "PA". ...\SB\SB.sln
at Microsoft.Build.Shared.ProjectFileErrorUtilities.VerifyThrowInvalidProjectFile(Boolean condition, String errorSubCategoryResourceName, BuildEventFileInfo projectFile, Exception innerException, String resourceName, Object[] args)
at Microsoft.Build.Construction.SolutionFile.ParseSolution()
at Microsoft.Build.Construction.SolutionFile.ParseSolutionFile()
at Microsoft.Build.Construction.SolutionFile.Parse(String solutionFile)
at Dnt.Commands.Packages.SwitchPackagesToProjectsCommand.SwitchToProjects(ReferenceSwitcherConfiguration configuration, IConsoleHost host) in C:\projects\dnt\src\Dnt.Commands\Packages\SwitchPackagesToProjectsCommand.cs:line 0
at Dnt.Commands.Packages.SwitchPackagesToProjectsCommand.RunAsync(CommandLineProcessor processor, IConsoleHost host) in C:\projects\dnt\src\Dnt.Commands\Packages\SwitchPackagesToProjectsCommand.cs:line 29
at NConsole.CommandLineProcessor.ProcessSingleAsync(String[] args, Object input)
at NConsole.CommandLineProcessor.ProcessAsync(String[] args, Object input)
at NConsole.CommandLineProcessor.Process(String[] args, Object input)
at Dnt.Program.Main(String[] args) in C:\projects\dnt\src\Dnt\Program.cs:line 33
We have hundreds of solutions and, sadly, most of them ignore MS guidelines and have projects with the same name.
@RicoSuter I'd be happy to fix it myself if you point me in the right direction. Thanks!
The text was updated successfully, but these errors were encountered:
I don't think you can fix that.. the exception comes from the Microsoft.Build namespace (which are dependencies of dnt) - if at all you'd have to talk to the guys in charge of the MSBuild tools. The alternative would be to write your own sln parser and replace the usage of the MSBuild sln parser. You'd start with using (var projectInformation = ProjectExtensions.LoadProject(solutionProject.AbsolutePath, globalProperties)) in SwitchPackagesToProjectsCommand . But you'd probably spend quite a bit of time ripping everything out.
Though, how do you get your dev environment to even load an .sln that MS considers invalid? I guess I'm not getting how your projects look. Switching the solution SA would work, right?
When you switch SB, your switcher file would say to replace package SA.PA with project PA. If PA is already in the SB.SLN, it shouldn't be re-added - so after the switch SB.SLN should contain PA and PB, no?
Let's say we have a solution SA with project PA that builds package SA.PA, and solution SB with projects PA and PB. Project PB uses a package SA.PA. Running
switch-to-projects
on SB throws an exception in this case. PA (from SA) is actually added to SB after that but the PackageReference to SA.PA in PB is not replaced.Exception:
We have hundreds of solutions and, sadly, most of them ignore MS guidelines and have projects with the same name.
@RicoSuter I'd be happy to fix it myself if you point me in the right direction. Thanks!
The text was updated successfully, but these errors were encountered: