-
Notifications
You must be signed in to change notification settings - Fork 258
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
packages.config (PC) to PackageReference (PR) Migration #5877
Comments
You might want to add #5894 to your list of issues to be fixed. Since NuGet contains WPF assets, this could bite you. |
Done. |
As I understand it, 465204 is also a scenario that works with packages.config but not PackageReferences |
roslyn 22095 is one that is stopping us from migrating. I had it as a nuget issue originally. If nuget could have a type of lib that ended up being output to bin but would be flagged as not having its API exposed to consuming projects, then it wouldn't be a problem. |
@mungojam NuGet packages can already depend on another package without exposing the API from that package to their own consumer. I think that that problem is solved at the right place right now because, for example, if package A depends on package B, we might say the ideal situation is that package A hides package B from the compiler of the app project if and only if no APIs from package B are exposed from package A's API. Let's take an example: Package B defines But now consider The issue that remains, I think, is that most packages out there today don't do due diligence to mark their dependencies carefully in this way. And even if a package author wanted to, it's not trivial to audit your public API for dependencies of this kind, nor to maintain that properly over time. So tooling to automatically discern between public dependencies and internal dependencies, and possibly automatically setting the appropriate package dependency metadata may be the best way to solve your problem in general. |
@AArnott Thanks for reviewing it, you've summed it up perfectly. I may be missing a trick then, how do we specify that a particular dependency is only to be added as an internal dependency and not exposed to compiler further up the chain? I agree that tooling would definitely solve it nicely if the nuget mechanism exists already. |
@AArnott Is this the mechanism you are referring to, using contentFiles? <contentFiles>
<file include="bin/Release/SomeInternalDependency.dll" buildAction="None" copyToOutput="true" flatten="true" />
</contentFiles> I might see what happens with a wildcard in the include. Maybe we could do that for the packages we make and then add external dependencies explicitly in an exclude.. sounds yukky, but might work. |
No, don't use contentFiles for this. When building your own package via csproj with <PackageReference Include="PackageB" Version="1.0" PrivateAssets="compile" /> This makes it so your own package A consumes and references package B in your compiler references, but folks consuming package A will not get package B in their assembly references. |
Thanks, that does work, actually using "compile;contentfiles;analyzers;build" to keep the default behaviour of PrivateAssets for the other types. So, I will raise a feature request for the tooling improvement that you suggested, recognising that it won't be an easy thing to implement. By the way, I had tried PrivateAssets previously and hit various errors. Some my own doing (package name clash). Other issues I ran into have been raised as issues already against the project system I think. I had to keep closing VS 15.4 and deleting obj/bin/.vs folders for various changes to package references to work. I hope that is fixed soon as it is a blocker for us too. |
Is it the case that #4491 should be included in this checklist? |
The same approaches can be extended to bundling rules. IMO, the system is broken if a file is both autogenerated and requires post-generation user edits before it works for them. Making |
@binki, while I agree that separating |
I’m convinced it is a big part of it. The installation/uninstallation scripts that
Where are the docs on this? I don’t expect NuGet package authors to write targets to work with one person’s way of autogenerating configuration files because there is not yet a right way to do so. Microsoft needs to make a guide on how to write a NuGet which can be installed into an ASP.NET project as |
@binki, I'm afraid we'll have to disagree on this. Separating out the config file introduces way more problems then it solves (especially at runtime where multiple files are now needed) just to get PR to work and there are still cases where PR won't work with a package. Since ASP.NET is deprecated in lieu of ASP.NET Core (which focuses on programmatic configuration and JSON instead of
configSource is what handles this. Some larger apps use it to separate their configurations out. Personally I find it harder to work with but I can see the draw for really large apps. |
I know what
OK, so I am reading that is: MS does not intend to fix this issue. Thanks for the update! |
I don't work for MS so I cannot answer the official word on the matter but if you read all the information coming out, including .NET 5 then the writing is on the wall. |
I see following error. Microsoft Visual StudioOperation failed Project is not eligible for migration. Either the project is not packages.config based or doesn't support PackageReference yet. Visit https://docs.microsoft.com/en-us/nuget/reference/migrate-packages-config-to-package-reference for more information.OKMicrosoft Visual Studio Enterprise 2022 Installed Version: Enterprise Visual C++ 2022 00476-80000-00000-AA668 .NET Core Debugging with WSL 1.0 ASP.NET and Web Tools 2019 17.1.165.16736 ASP.NET Web Frameworks and Tools 2019 17.1.165.16736 Azure App Service Tools v3.0.0 17.1.165.16736 Azure Functions and Web Jobs Tools 17.1.165.16736 C# Tools 4.1.0-2.21558.9+518162cc0ccd9f90a309d4acdd5a22886865b77c Common Azure Tools 1.10 Fabric.DiagnosticEvents 1.0 Microsoft Azure Service Fabric Tools for Visual Studio 17.0 Microsoft Azure Tools for Visual Studio 2.9 Microsoft JVM Debugger 1.0 Microsoft Library Manager 2.1.134+45632ee938.RR Microsoft MI-Based Debugger 1.0 Microsoft Visual C++ Wizards 1.0 Microsoft Visual Studio Tools for Containers 1.2 Microsoft Visual Studio VC Package 1.0 Node.js Tools 1.5.31027.1 Commit Hash:dac60d9b246a1d6a5daf23d223c933dbe1518465 NuGet Package Manager 6.1.0 ProjectServicesPackage Extension 1.0 Razor (ASP.NET Core) 17.0.0.2152601+724154d925d7d9d26ebf8a73a66d5219aa320400 Snapshot Debugging Extension 1.0 SQL Server Data Tools 17.0.62111.10130 TypeScript Tools 17.0.1029.2001 Visual Basic Tools 4.1.0-2.21558.9+518162cc0ccd9f90a309d4acdd5a22886865b77c Visual F# Tools 17.1.0-beta.21558.1+467d1b5daffaf2a3f0052fc366c91b11131e6528 Visual Studio Code Debug Adapter Host Package 1.0 Visual Studio Container Tools Extensions 1.0 Visual Studio IntelliCode 2.2 Visual Studio Tools for Containers 1.0 |
Issue is missing Type label, remember to add a Type label |
Can Microsoft please provide an official statement if PackageReference will or will not be supported by ASP.Net .NetFramework projects? |
Under Project type support:
|
Only partially true, as @daniatic says ASP.Net projects currently only work with packages.config, if you try to migrate manually it fails in several ways. |
I'm referring to the docs, that state:
Limited Support is linked to this specific issue. It is not easy to deduct, what limited support means. Is it limited support regarding the migration? Or is it limited support in general with asp.net with .net Framework? And what are these limitations? Will they be fixed? Am I supposed to read through the 91 preceding comments to get an answer? I could but I'm afraid that I won't get an thorough answer... |
What's the source? What are those ways? Been using (hundreds of) That's support for SDK-based projects. Not the same thing. |
@khellang the two known issues that I'm aware of are config transforms and transient binding redirects. Note that you can use package references in any project but you have to be aware of the limitations as it isn't formally supported. Config transforms used to be the biggest issue. Many packages, pre SDK, made changes to configs using Nuget's install/uninstall feature. This was dropped with package references so they can no longer make changes. The biggest package impacted by this was EF but there were many others including Dotnet Compilers. Because PRs do not run the install/uninstall scdripts then no changes are made. If the config changes were never really needed (e.g. EF) then you would never notice the issue. But Roslyn, for example, wouldn't work properly. To remedy this the package format was updated to support build files (targets and props). Most packages were updated to use this route and so you don't see the problem but older packages would continue to have problems. Another area is transient dependencies which PRs support but package.config does not. This problem tends to rear its head when you upgrade packages. The problem comes in when you have multiple dependencies on the same third party package. You can get into versioning conflicts so you have to use binding redirects. With PRs you only need to depend on the packages your project uses and Nuget will pull in the rest but that doesn't work properly without SDK projects. In that case you can see runtime errors because the binding redirects aren't updated for transient dependencies unless you're using SDK projects. If your code happens to build in the "correct" order you may not see this problem for years but at some point an upgrade of a package or a change in build order can suddenly reveal that your project has a bad binding. The general workaround is to add the transient dependency as a direct dependency. This resolves the issue generally bad at the cost of an 'unneeded" dependency. We too have a couple of ASP.NET projects using PRs but it is not a supported situation and we have docs that discuss how to handle the issues it causes. In at least one case we reverted back from PRs when trying to update the project at a later date because we could not get around the binding issues. So if you have it working in your projects then great for you, but it still isn't formally supported. |
Status: In Progress
Issue to track new feature work around enabling packages.config (PC) to PackageReference (PR) upgrader workflow.
Here is the link to the spec.
Feel free to comment below with your feedback.
Related issues
#12388
Overall Issue Description:
Likely Project System Issues
contentFiles under "any" folder doesn't work with PackageReference-style with classic csproj dotnet/project-system#3042 - ContentFiles "Any" folder issue with classic csproj
Show contentFiles from nuget packages in legacy project system dotnet/project-system#3431 Display ContentFiles in Legacy PR
Enable EmbedInteropTypes for PackageReference (matching Packages.Config capability) #2365 - Some assemblies in NuGet packages should be linked, not referenced (Pertains to interop assemblies and the knowledge of whether an assembly needs to be referenced. Lost when moved to the transitive world)
Linking embedded interops in package reference dotnet/project-system#2859 - Project System side ASK for embedded interops
PP transforms - supported, but csproj.dll issue (link?) (see related Fix 4.3 regression - Placeholders $product$ and $AssemblyGuid$ not replaced in contentfile through transformation #5880)
ContentFiles doesn't work with legacy PackageReference. Some issues in NuGet but also needs to coordinate with Project System as well. (ContentFiles are not added as link items in standard PackageReference #5958 PP file output is not generated during the build in classic c# project dotnet/project-system#2861)
CPS projects can't handle contentFiles from separate packages using the same file name. (CPS projects can't handle contentFiles from separate packages using the same file name #5048)
https://devdiv.visualstudio.com/DevDiv/NuGet/_workitems/edit/567298 - Wildcard support in legacy project systemWon't fix.Internal bug 465204 - NuGet Build Tasks don’t put proper metadata on satellite assemblies (potentially a restore issue)
NuGet Migration Issues:
NuGet PC to PR Migration Tool Issues
Changes to NuGet PM UI to adapt to transitive:
VS Extensibility Team Issues
C++ Team Issues
WPF Project Compat Issues:
Clean up our own Repro to remove the need for install.ps1
Work with package owners (see related item# #5960)
Validation to improve ecosystem for new push/ingested packages
Package Reference experience issues
The text was updated successfully, but these errors were encountered: