Creating NuGet Packages - Why doesn't this folder structure work for .NET 4.0? - .net-4.0

Here is the issue I'm having - I cannot get my project's NuGet package to work for .NET 4.0.
Here is what my folder structure looks like:
lib\
\.NET 4.0
binary.dll
\Silverlight 4.0
binary.silverlight.dll
Whenever I try to add this package to a Silverlight 4 project, it works just fine. When I try to add it to an ASP.NET MVC3 app I get the following error: "unable to find assembly references that are compatible with the target framework '.NETFramework, version=v4.0'"
What am I doing wrong?

Change the folder name to Net40 and SL4 (or Silverlight4 no spaces). You should file a bug though, those names should work. I think the "." in .NET might be throwing it off.

Related

Project must provide a value for configuration

Project must provide a value for configuration. Msbuild failed wih this error and its working fine if doing build via vs 2017. But breaking when using Msbuild cmdline
Try deleting Microsoft.AspNetCore.Razor.Design in your .csproj file. That worked perfectly for me. I had the same issue, when I migrated my project from .NET Core 2.2 to .NET Core 3.0.

Can build and run on Visual Studio but cannot Publish

I am having a weird situation where I cannot publish my final Web project. Here is the project structure:
Foo.Services.Common: this is shared library: .NET Standard 2.0.3, Microsoft.AspNetCore.Mvc.Core 2.1.0 with the class DefaultWebSettings defined.
Foo.Services.Common.Razor: Razor Class Library, has reference back to Foo.Services.Common and uses DefaultWebSettings: NETStandard.Library 2.0.3, Microsoft.AspNetCore.Mvc 2.1.0 and some other ASP.NET Core related package (static files, Configuration)
Foo.Services.Api: ASP.NET Core API only (no View, no Razor), has reference back to Foo.Services.Common. Publish well. Uses: Microsoft.AspNetCore.App 2.1.0, Microsoft.NETCore.App 2.1.0.
Foo.Services.Web: front end project. This one is the one I cannot publish! This one has references to both Common projects. Uses: Microsoft.AspNetCore.App 2.1.0, Microsoft.NETCore.App 2.1.0
However, upon publish, this one shows up:
The type or namespace name 'DefaultWebSettings' could not be found
(are you missing a using directive or an assembly reference?)
The error location is in a file of Foo.Services.Common.Razor project, NOT the Web project.
Funnily, Visual Studio perfectly works even with IntelliSense and Go to Definition:
I can build in both Debug/Release mode, run with/without debug any project in the solution well. Moreover, publishing Foo.Services.Common.Razor works without any problem!
In short: I cannot publish my Web project and have no idea what is the problem. I have tried:
Clean/Build.
Delete/Re-add references.
Manually delete all obj and bin folders.
Please show me what I may missing.
In the end, I had to remove Reference of the Common from Common.Razor and Web projects. I guess they could not build because of some conflict between .NET Standard and .NET Core. Had to copy all code of Common into Common.Razor.

DotNet Core App 2.1 - Can't add DLL reference

I have a DotNetCore 2.1 Web App (just created it today from the VS 2017 scaffold). This solution also includes a DotNet Core 2.1 Library DLL project. The solution builds ok.
I have another (brand new) DotNetCore 2.1 Web App that wants to use the Library DLL. But when I try to add a new reference (on the Browse tab), it complains:
One or more errors occurred.
The reference is invalid or unsupported.
Any suggestions?
(Curiously, the DLL doesn't show up directly under the Bin\Debug folder like it does in classic .Net; It's under Bin\Debug\netcoreapp2.1)
I got this error after I moved some of my code repos around and suddenly my .NET Core 2.1 console app wouldn't recognize a .NET 4.5 DLL anymore when I added it.
Turned out that although the broken reference did not show in the solution explorer, the project file still contained it, along with the now broken HintPath to the DLL's old location. Manually removing this reference from the project file solved it.
Go into your .csproj and make sure the <Reference Include=... is pointing to the correct directory.
For example, my references were pointing to the bin\Debug path of another project when the only build that was actually there was the bin\Release
When you create a new project from the Visual Studio 2017 Class Library (.NET Core) template, the csproj file contains:
<TargetFramework>netcoreapp2.1</TargetFramework>
Since this is a library, it (apparently) needs to target netstandard2.0. (BTW, creating a library project from the dotnet command line command correctly targets netstandard2.0. Go figure.)
So changing the line in the library's csproj file to
<TargetFramework>netstandard2.0</TargetFramework>
and rebuilding the library now allows me to reference the library from the DotNet Core 2.1 (netcoreapp2.1) application.
I am converting lots of projects to .net6, and one of the projects suddenly refused to let me add .dll files. The solution was to remove the old references first, then add the new references. (The project had references to old .dll files with the same name as the new converted ones.)
Normally Visual Studio lets me add two dlls with the same name but different path, so I later can erase the old one, but in this particular case this did not work. A screenshot and Paint to the rescue for my memory!
In my case, I had a reference to duplicated .dll files. After removing duplication and changing references to different folders got the error above. Cleaning obj, bin and removing the .vs folder from the root directory helped
For me I had to add a nuget package instead of manually adding a reference. I was using .net 6 and needed System.Drawing so I added the System.Drawing.Common package.
https://www.nuget.org/packages/System.Drawing.Common/

Netcore 2.0 publish is not copying SDK dlls

I am trying to publish a Netcore 2.0 application with MSBUILD.
The published output is missing all the SDK dlls such as Microsoft.AspNetCore.Hosting.dll (there are a lot) so when I try to run the application from command line with dotnet appname.dll I get the error saying that it can't find the referenced dll...
I have published other applications before (not created by me) and the publish copies the dlls and also has a "refs" folder which mine does not have.
So I am pretty sure it's a project configuration issue but I have been searching for hours and there is no information on what I should change.
Turns out there was a nuget reference on my project called Microsoft.AspNetCore.All...
For some reason uninstalling this reference solved the issue and now the publish output contains all the SDK dlls
The ASP.NET Core dlls are part of the runtime store that is included in the runtime & hosting bundle installations so they don't need to be included in the publish output. (note that this is going to change in the 2.1 timeframe)
To disable the use of the ASP.NET Core runtime package store, you can set this in your project file:
<PropertyGroup>
<PublishWithAspNetCoreTargetManifest>false</PublishWithAspNetCoreTargetManifest>
</PropertyGroup>

Issues while upgrading System.Web.Extensions dll reference from 3.5 to 4.0

I need to migrate a website built on .net framework 3.5 to 4.0 and it should work fine in IE9
The solution got upgraded by the VS's version utility and the app compiled successfully. We are using Infragistics UltraWebGrid control v11.1 which is giving some script issue when we try to perform scroll or cell edit. The control has got lot of embedded javascript resource files which seems to be not working fine.
I created a poc website of .net framework 4.0 using the same third party dlls and everything works fine. What I can doubt on is the AJAX part. I tried to consume v4.0 of ajaxcontroltoolkit. But the issue what I am facing is, the toolkit internally references System.Web.Extensions.dll of version 4.0 and my application has many references to the dll of v3.5. Adding the reference to v4.0 doesn't replaces the references to v3.5 in the web.config. Finally I manually updated the version info in web.config which has given birth to other errors.
-Unknown server tag 'asp:ScriptManager','asp:UpdatePanel' etc..
-The type or namespace name 'Script' does not exist in the namespace 'System.Web' (are you missing an assembly reference?)
Please give me some suggestions to upgrade the dll references successfully.
Thanks,
Vaishali