Comments (7)
Hmm maybe we need to restore in the reverse order to fix this scenario?
from dnt.
Hmm maybe we need to restore in the reverse order to fix this scenario?
Didn't looked at your code, but it was the first thought crossed my mind.
from dnt.
We are having the same issue. Ideally dnt would not switch the recursive 'child' projects at all. We would rather run 3 separate switcher commands to keep everything in sync.
from dnt.
Same issue with me. Dnt is great tool, but this issue is stopping me using it at full potential.
from dnt.
Can confirm this behaviour. I'm presently still using the tool and just manually keeping track of cleaning up the recursive fixes for going back from projects to packages, but it'd be nice to have the tool handle it. I'll try and take a peek at the code and see how involved it'd be to fix.
from dnt.
So, it seems this is the culprit:
SwitchProjectsToPackagesCommand
line 123
if (!mappedProjectFilePaths.Contains(projectFileName) || !configuration.RemoveProjects)
mappedProjectFilePaths
contains a list of all projects in the mapping file. I'd argue that if switch-to-projects
was used, and replaced something, switch-to-packages
should undo that.. switch-to-projects
after all keeps track of what was replaced in every fle it touched, but the condition above prevents a full rollback unless you set RemoveProjects
to false.
Alternatively, switch-to-projects
should be made to only swap out packages that have been specified - so if a file looked like this:
{ "solution": ConsumerC.sln, "mappings": { "CommonC": [ "../CommonA/CommonA.csproj" "../CommonB/CommonB.csproj" ] } }
With this file, I'd expect the project CommonB to remain unchanged, and CommonC would have CommonA and CommonB replaced by .csproj files. But in my tests with a more complex file (
{ "solution": ConsumerC.sln, "mappings": { "CommonA": "../CommonA/CommonA.csproj", "CommonB": [ "../CommonA/CommonA.csproj" ], "CommonC": [ "../CommonA/CommonA.csproj" "../CommonB/CommonB.csproj" ] } }
) I ended up having duplicate .csproj references.
from dnt.
@RicoSuter been debugging both switch-to-projects and switch-to-packages. And one thing I don't get:
switch-to-projects
parses the solution, adds any .csproj from the switcher config that's not already present in the .sln, then goes through all projects in the .sln (AFTER adding the additional .csproj files), and replaces any package reference with the project reference. So, that it recursive- every project added to the .sln gets its packages replaced - including projects that were not part of the original .sln.
switch-to-packages
on the other hand does not touch any .csproj that was only added due to execution of switch-to-projects
unless removeProjects
is false.
So, the operation is asymmetrical and leaves some the final result different from the starting point. Now, switcher.json being updated and containing the entirety of package replacements for all csproj, shouldn't dnt simply skip line 123 in SwitchProjectsToPackagesCommand
? We have configuration.Restore
that tells us how packages were switched to projects - I'd argue that these changes should be fully restored on switch-to-packages
regardless of whether projects added to the solution are removed again. I guess I'm saying I can't figure out the argument for doing it differently. Before I make a PR that gets rid of that condition I'd rather check with you. My alternative approach would just be adding a new switcher file flag to override the skip condition.
from dnt.
Related Issues (20)
- DNT fails with "Could not load file or assembly 'System.Runtime, Version=6.0.0.0'" HOT 9
- InvalidCastException when mixing "single project per package" and "multiple projects per package" HOT 1
- Support for <Import tag in `switch-to-projects`
- problem with special characters in solution name and/or path HOT 1
- Swtich to proj references: iInvalidProjectFileException: The SDK 'Microsoft.NET.Sdk.Web' specified could not be found
- Switcher configuration with a combination of single project and multiple project are flattened after switch-to-projects HOT 2
- [Question] Use without `.sln` file?
- switcher - support for duplicated project names HOT 2
- .NET 7 Preview version causing DNT to fail (we had the same problem when we moved from 5->6) HOT 12
- Keep ItemGroup Condition when switching projects <-> packages HOT 1
- switcher - support for GeneratePathProperty HOT 4
- debugging dnt - how to get started HOT 1
- What does "d"/"t" mean in Type for used-packages ?
- bump-versions without GeneratePackageOnBuild
- switch-to-projects with MSIX: Unable to find project information for MyNugetProject.csproj HOT 1
- switch-to-projects: Is it possible to exclude projects?
- Issues when using DNT with newest Visual Studio Build Tools 17.8.0 HOT 6
- Difficult to understand error when switcher.json file has spelling mistakes. HOT 2
- Switch-to-projects where packages have references between them HOT 1
- Error when attempting to process .vcxproj
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dnt.