I need help.
My project has recently moved from .NET Framework 4.8 to NET 6. We have everything uplifted and compiling, including the migration from packages.config to PackageReference.
This project is somewhat unique in that it has:
An outward-facing Git repository that can connect to the internet
A private Git repository that is offline
This means we have two builds, one for each repository. To accomplish this, we have to copy the code and Nuget packages from the outward-facing Git repo to the private Git repo. Obviously, we only want to copy the Nuget packages that are required since some packages already exist on the systems that use the private Git repo (e.g., NET 6 packages, DevExpress packages, etc.).
Here's the issue.
When I build the solution from Visual Studio on my laptop, the global packages folder contains 204 packages. When I guild the exact same solution from Visual Studio on our public build system, the global packages folder contains 125 packages. The total number of packages should be the same regardless of outward-facing system, and for the life of me, I cannot figure out why this is happening or how to fix it.
We have a NuGet.config file located in the solution folder (content below). I have built using Visual Studio with Diagnostic output enabled and verified that the exact same NuGet config files are referenced and have the same content between my laptop and the public build system. This would lead me to believe that there is software (perhaps Visual Studio components?) installed on the public build system that are referenced from their installation location, but my laptop is having to pull them from one of the package sources. I simply don't know what else it could be, but I don't see any differences in this regard.
Can anyone suggest things to investigate?
Here's our local NuGet.config file content:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<config>
<add key="globalPackagesFolder" value=".\packages" />
<add key="dependencyVersion" value="Highest" />
</config>
<packageSources>
<clear />
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
</packageSources>
<packageRestore>
<clear />
<add key="enabled" value="True" />
<add key="automatic" value="True" />
</packageRestore>
<bindingRedirects>
<clear />
<add key="skip" value="False" />
</bindingRedirects>
<packageManagement>
<clear />
<add key="format" value="1" />
<add key="disabled" value="False" />
</packageManagement>
</configuration>
(I know this isn't an answer, but it's too long for a comment... hopefully it can develop as we learn more)
A couple ideas of where to look for differences:
Find the project.assets.json files in the obj folder for each project and compare between the builds. This will show any differences in the restore graph that NuGet is generating.
Generate a binary log (binlog) from each build using the /bl flag (e.g. dotnet build -bl or mbuild /bl depending on your build). Use https://msbuildlog.com/ for reading the binlogs. You can find the references in each project build, and compare those (more manual, but each set of references can be sorted and then copied and diffed in a text editor). This might help show if some references are coming from an install location. One place to start might be to search for $rar (this is a shortcut for $task ResolveAssemblyReferences), and look at the different OutputItems, expanded and sorted.
Compare results of building on the command line vs. in Visual Studio. This can help isolate if VS is doing something to interfere or change the build.
The problem was that the .NET 6 SDK was not installed on our public build system. Let me see if I can explain.
Up until November 2022, we were only targeting the .NET Framework, so we never had a reason to install the .NET SDK when upgrading Visual Studio. In late November, some of the members of our team began uplifting our solution to .NET 6 using the Visual Studio version we already had installed (17.2.9, I believe). Obviously, they had to have the .NET 6 SDK installed on their local systems in order to build locally. It is unclear whether they updated their Visual Studio version locally or downloaded the .NET 6 SDK directly.
In any case, after the holidays, I began working to update our build system. One of the first things I did was update Visual Studio to v17.4.4 on my laptop, our public build system, and our various offline systems. I made sure to check the .NET SDK option on the Individual Components page. I assumed this installed the .NET 6 SDK on these systems.
I was wrong.
Visual Studio 17.4.4 delivers the .NET 7 SDK, but we are specifically targeting .NET 6 because it is the long-term support version.
At some point in my efforts, I had apparently downloaded and installed the .NET 6 SDK on my laptop, but failed to make the connection that this needed to be done across the other systems as well.
Thus, building on my laptop pulled the .NET 6 packages correctly (204). On the public build system (which did not have the .NET 6 SDK), building resulted in a cadre of packages being pulled from the internet and the local .NET 7 SDK (125).
Once I installed the .NET 6 SDK on the public build system, it pulled the 204 packages that I was expecting.
A huge shoutout to Jimmy for his suggestions. I hope that between his answer and this one, others might find benefit.
Related
All,
We've just been having some fun and games with the error "Spatial types and functions are not available for this provider because the assembly Microsoft.SqlServer.Types version 10 or higher could not be found".
We were migrating a .Net Framework 4.7.2 MVC application from Windows Server 2012 with SQL Server 2016 combination to one of Windows Server 2019 with SQL Server 2019.
Once migrated the application on the new environment fired up OK but this error occurred while using it.
The weird thing was all instance of Microsoft.SqlServer.Types appeared to be version 14 which made nonsense of the error message.
Comparing servers, we noted that "MicroSoft System CLR Types for SQL Server" was installed on the Windows Server 2012 web server so we added "MicroSoft System CLR Types for SQL Server 2019" to the replacement server.
The issue still didn't go away.
Looking at the solution we noted that it used Version 14.0.1016.290 of Microsoft.SqlServer.Types was available but that Version 160.1000.6 was available so we updated that.
This still didn't fix the issue and we eventually realised that although we were attempting to update Microsoft.SqlServer.Types to Version 160.1000.6, the update was failing because it could not overwrite existing files and SqlServerSpatial140.dll was being left in place.
We removed all the SQLServerTypes, x86 and x84 directories which contained SqlServerSpatial140.dll then attempted to update the Nuget package again.
This still didn't work.
Then we took a look at the web.config and saw that even tough we had upgraded the Microsoft.SqlServer.Types package to Version 160.1000.6, the web.config still had it logged as
<dependentAssembly>
<assemblyIdentity name="Microsoft.SqlServer.Types" publicKeyToken="89845dcd8080cc91" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-14.0.0.0" newVersion="14.0.0.0" />
</dependentAssembly>
We update the 14 to 16 as follows
<dependentAssembly>
<assemblyIdentity name="Microsoft.SqlServer.Types" publicKeyToken="89845dcd8080cc91" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-16.0.0.0" newVersion="16.0.0.0" />
</dependentAssembly>
That seems to have done the trick.
It seems nuts that a Nuget Package could be so problematic so maybe there's something about this solution and how it is set up which is contributing to this.
Note that we were using Visual Studio 2022 for this and the application is written in c#.
Either way I hope this experience is useful to others.
I have a .NET Framework 4.5 project (C# language) in Visual Studio 2019.
I'm tryng to use Crystal Reports.
When I write ReportDocument r = new ReportDocument(); this throw this exception:
Could not load file or assembly 'System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. Impossibile trovare il file specificato.
How can I solve?
Try adding this to your App.config file:
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
</startup>
In the past the "Crystal Reports for .NET Framework 4.0" used to target the 2.0 CLR for whatever reason. They have fixed this in later versions but it could be related to your issue. You will also want to verify you have the .NET Framework 4.x installed (I'm assuming you do). You might also double check that your project has a reference to System.Windows.Forms and if not try adding one and see if it helps.
If those don't work, consider installing the latest service pack from SAP for the version of Crystal Reports you're using. The version of Crystal I use is on SP 30 something. Those libraries now actually target the 4.x framework. I don't know the version you're using so I can't provide a direct link but you should be able to search SAP's site for it.
I followed the instructions of nuget license here.
I use the following code in myproject.csproj:
<PropertyGroup>
<PackageLicenseFile>LICENSE.md</PackageLicenseFile>
</PropertyGroup>
<ItemGroup>
<None Include="..\LICENSE.md" Pack="true" PackagePath=""/>
</ItemGroup>
The Nuget package is built correctly.
No build error or warning related to license.
The license file is included in the package correctly.
When I Inspect the nuspec file in the package, I find this xml code:
<license type="file">LICENSE.md</license>
<licenseUrl>https://aka.ms/deprecateLicenseUrl</licenseUrl>
In MyGet feed package, it show package license as UnKnown and point to: 'https://aka.ms/deprecateLicenseUrl'.
My Question:
Why the nuspec file included in the package show deprecateLicenseUrl?
What I missed to show license in MyGet correctly?
Why the nuspec file included in the package show deprecateLicenseUrl?
Embedded licenses were added to the NuGet client in NuGet 4.9, which corresponds to Visual Studio 2017 15.9, around November 2018. Before then, only license URLs were supported. This means that Visual Studio 2017 15.8 and earlier, as well as Visual Studio 2015 and earlier do not support embedded licenses, and so the license URL pointing to the documentation is added so that they show something, allowing customers to understand why they can't see the real license and instructions on how to find the actual license for the package. Similarly, it means that NuGet feeds need to change to support embedded licenes. The NuGet client team worked with the nuget.org team to make sure they both supported it at the same time, but the NuGet team has no direct influence of other NuGet feed implementations. If MyGet has not updated to support embedded licenses, it can use the lincense url backwards compatibility aimed at users of old versions of Visual Studio.
What I missed to show license in MyGet correctly?
You could use both embedded license and a custom license URL, but then NuGet will generate warnings when you pack, and your package may be rejected if you try to pubilsh to nuget.org. Otherwise you haven't missed anything, it just sounds like MyGet hasn't "kept up" with changes to NuGet.
I'm trying to connect to a db2 instance using EF6 and the new IBM Entity Framework data provider found here
have added the provider to the app config:
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
<provider invariantName="IBM.Data.DB2" type="IBM.Data.DB2.EntityFramework.DB2ProviderServices, IBM.Data.DB2.EntityFramework, Version=10.5.5.6, Culture=neutral, PublicKeyToken=7c307b91aa13d208" />
</providers>
and connection string looks like so:
<add name="DB2" connectionString="Server=blah;Database=meh;Uid=user;Pwd=pword;" providerName="IBM.Data.DB2" />
I can instantiate a context but when I try to run a query it throws a MethodAccessException:
Attempt by method 'IBM.Data.DB2.EntityFramework.DB2ProviderServices.GetDbProviderManifestToken(System.Data.Common.DbConnection)' to access method 'IBM.Data.DB2.DB2Trace.Entity_CheckDB2Trace()' failed.
I have installed the DB2 Version 10.5 Fix Pack 5
Any ideas as to what I might be doing wrong?
Turns out I had installed the 10.5.5 driver but it failed to be set as the default. After running the "Default DB2 and Database Client Interface Selection wizard" (found just by searching in the start menu) and setting the new one as the default it worked fine
#Ramu, I have recently started migrating one of our legacy applications and started figuring out how to connect to IBM DB2 using Entity Framework 6. To answer straight to your question - its not possible to work in VS 2015 as IBM database add-ins are supported only until VS 2013. We have contacted IBM and they have no idea if they are going to release these add-ins for VS 2015.
As a work around I built my repository in VS 2013 and made it as a nuget package. I have imported that package into my VS 2015 project. Now packages are much cleaner way of doing it than giving hard dll references.
This is how I setup the environment
Install IBM DB2 10.5 with Fix-pack 7. That should get IBM Data server Client 10.5.
On the same installation package – Install IBM Database Add-Ins for Visual Studio.
Install IBM Data server Driver 10.5.
Install EF Tools for VS2012/VS2013
Go to programs and features - and always make sure both IBM Data server client and IBM Database add-ins for VS should have same version, release and fix-pack level.
Hope this helps.
I have standardly setup WPF project with Entity Framework 6 and SQL Server Compact 4.0 installed.
When I build my project all the necessary files for SQL Server CE deployment are correctly copied to the Release folder, including System.Data.SqlServerCe.dll.
But running project on a machine without SQL Server Compact installed throws System.IO.FileLoadException.
In my development environment is the System.Data.SqlServerCe.dll loaded from GAC. I have found this reference, where the version numbers of dlls are explained: http://technet.microsoft.com/en-us/library/gg213826.aspx
I supposed that the version of System.Data.SqlServerCe.dll assembly form NuGet is 4.0.0.0.
So I have manually changed System.Data.SqlServerCe.dll reference in my project to 4.0.0.1 file form the Private folder and copied System.Data.SqlServerCe.dll 4.0.0.1 to the production machine.
I have changed app.config like that:
<system.data>
<DbProviderFactories>
<remove invariant="System.Data.SqlServerCe.4.0" />
<add name="Microsoft SQL Server Compact Data Provider 4.0" invariant="System.Data.SqlServerCe.4.0" description=".NET Framework Data Provider for Microsoft SQL Server Compact" type="System.Data.SqlServerCe.SqlCeProviderFactory, System.Data.SqlServerCe, Version=4.0.0.1, Culture=neutral, PublicKeyToken=89845dcd8080cc91"/>
</DbProviderFactories>
</system.data>
Now I get this exception on development machine:
The connection given is not of type 'SqlCeConnection'.
On production machine I get System.Data.Entity.Core.EntityException.
Is there any chance to get private deployment working with NuGet and EF 6? Or is it necessary to copy manually all the files in x86, amd64 folders?
The System.Data.Entity.Core.EntityException was already problem within my app, I also forgot to change DB name after deployment.
I have followed this guide and it is working now:
http://erikej.blogspot.sk/2013/11/entity-framework-6-sql-server-compact-4_25.html