Publishing node_modules in Visual Studio 2017 - asp.net-core

I'm using a devexpress reporting widget that requires node_modules folder, the folder is not visible on my solution explorer until I click on "Show all files"... the issue is when I published initially I got an error of the node_modules directory not found, and when I contacted devexpress support, I was asked to right click on node_modules folder and click "Publish node_modules" to fix that error but when I do so I get this error:
Preparing to publish files...
Connecting to bin\Release\PublishOutput...
Unable to open the Web site 'bin/Release/PublishOutput'. The Web site 'bin/Release/PublishOutput' does not exist.
Unable to open the Web site 'bin/Release/PublishOutput'. The Web site 'bin/Release/PublishOutput' does not exist.
I do not know anything about node_modules other than I need for my reports to display. Any help/explanation would be appreciated. By the way my project is an Asp.Net Core web app.

i have fixed the issues thanks guys, i just deleted most of the folders in the node_modules that the devexpress reports do not require and inclufed the folder in my project

Related

Using nuget packages on machine with no internet

I have a .net core intranet web app which uses certain nuget packages. I have two machines, my local computer with internet and a test machine with no connection to outside internet. The app works fine on my computer.
All the nuget packages are locally stored and referred by the web app.
When I try to build the app on test machine, I am getting the following error
C:\Program Files\dotnet\sdk\3.0.100\Nuget.targets(123,5): error : Unable to load the service index for source https://api.nuget.org/v3/index.json
What process is actually looking for service index from outside url? Of course it cannot find because there is no internet. No proxies involved so nothing to put in nuget.config
All the packages are locally stored. What can I do to resolve this issue?
Thank you
You’ll need a local folder to keep all your local NuGet packages..
Then download the NuGet packages you wish to be able to use offline into this folder. Packages can be downloaded from nuget.org.
Once you are logged in, search for the packages you require and click the ‘Download’ link in the left hand menu of each.
Once you have successfully downloaded the .nupkg files you require into your local repository folder, head into Visual Studio and open the NuGet Settings dialog via Tools > NuGet Package Manager > Package Manager Settings. Click the Package Sources tab within the settings dialog, followed by the ‘plus’ icon in the top left to add a new package source.
Enter the Name and Source of your local repository. The name can be any string and will be the name displayed in the NuGet Package Manager within Visual Studio.
Now that you have added the local package source, you will be able
to use your offline local repository from within Visual Studio in
the usual way, either via the Console or via the Package Dialog, by
selecting it from the Package Source menu, without the need for an active internet connection.

System could not be found Visual Studio 2017 ASP.NET Core project

I've installed the newly released version of Visual Studio 2017 and started a fresh ASP.NET Core project targeting .NET Core.
Out of the box, I'm getting the
The type or namespace name 'System' could not be found (are you
missing a using directive or an assembly reference?)
error. Any idea what's causing this and how to fix it?
Also, looks like there are problems with NuGet packages as well:
I also tried dotnet restore on the project through the command line and got the following error:
P.S. Kind of disheartening that you get an error in a fresh new project in the latest version of Visual Studio 2017!
UPDATE:
SDK version is v 1.0.1 -- see below:
UPDATE 2:
This is very strange. Looks like the original problem was due to NuGet package source pointing to a folder under Visual Studio 2015 folder. I unchecked it and left only nuget.org. With that my project seemed to have restored all the packages and when I started the project it loads up the standard ASP.NET page. But if I open startup.cs file, I get red squigglies all over the place but if I run the project, it works fine. What's going on here?
UPDATE 3:
I closed the project and VS 2017. I then restarted VS 2017 and opened the project and now it seems to be fine. And I'm not referencing the .NETStandard library 1.6.1 and everything seems to be working fine now.
I had the same issue in my Visual studio 2017 .Net Core application. I closed the Visual studio and re-open fixed everything.
Came across the same issue today. I had an old nuget source that no longer existed. So I went into Tools > Nuget Packet Manager and un-checked the wrong one. Hit "Ok", and then rebuilt the project, and it works great now. It seems like you stumbled onto it, but also wanted to verify that it fixed my issue, and it does.
I had the same problem, first when converting a VS2015 net core mvc web project to 2017 and then when trying to create a new core web application in 2017.
Went to Tools|NuGet Package Manager|Package Manager Settings - checked 'Allow NuGet to download missing packages' and 'Automatically check for missing packages during build in VS' and then clicked 'Clear All NuGet Cache(s)'.
Then re-built the solution - it found and loaded all the required packages and ran OK.
May not work for all cases but simple and worth a try.
Multiple closing and reopening of VS2017 fixed it for me.
I had the same issue, the solution for me was to clear the NuGet cache. Tools > NuGet Package Manager > Package Manager Settings > Clear All NuGet Cache(s)
Check the version .NET Command Line Tools in CMD, just type dotnet --info. If version is 1.0.0, then try to install latest version .NET Core SDK from here.
Find the broken project and right click, Unload, right click, Re-load. Fastest fix for me.
If you get the problem while using the CLI, try doing nuget restore instead of dotnet restore as that sometimes pulls down packages that the dotnet CLI seems to miss.
I have had the same issue with Visual Studio 2019 and .NET Core SDK 2.2.
These steps solved the problem:
Close the Visual Studio
Open the Visual Studio as Administrator
Open the Solution
Right click on Solution -> Restore NuGet Packages
I've tried all answers above. For me works only removal and adding the reference again described in the following steps:
Open 'References' under the project.
Right click on 'System' reference.
Click on 'Remove'.
Right click on 'References'.
Click 'Add Reference...'.
From right menu choose an 'Assemblies',
In a search field type 'System'.
Choose 'System' from the list.
Click 'Add' button.
IMPORTANT: Restart the Visual Studio.
'System' reference you can replace with any you need.
Try adding the following line above the other references in the csproj file
<Reference Include="netstandard" />
For me the problem was caused by my project having a custom IntermediateOutputPath. For some reason, if project_name.csproj.nuget.g.targets is not in obj subfolder of project folder, the error occurs.
Using default IntermediateOutputPath or keeping a shadow copy of project_name.csproj.nuget.g.targets in fake obj folder solves the problem for me.
This issue seems to be triggered by a myriad of reasons. Mine was caused by cloning directly from VSTS using Git Bash, my project directory had spaces in it. Git Bash changed those spaces in the path to %20. It was throwing off all the references in my project. So for anyone who tried everything else and are at their wits end, make sure %20 is not in the path.
So, I have cloned the repository from github and started getting this error.
It was my project uploaded from another machine. I later realized that I have used the materialdesign packages in my project.
I have uninstalled and reinstalled these packages and it fixed my issue.
Had the same problem. Uninstalled Application Insights from my projects using the nuget package manager. I'm not looking at that yet, I just wanted core and unit tests. Problem solved.
I also had the same problem.
The is no SDK folder under the Dependencies one. Therefore, no Microsoft.NetCore.App libraries !
To solve this problem, in Nuget manager window, install any nuget which depends on .NetCoreApp (you can install for example Microsoft.AspNetCore or BundlerMinifier.Core from the Microsoft Visual Studio Offline Packages source).
The SDK will be restored by the same time.
Once it is back, you can uninstall the previously added nuget. The SDK will remain in place.
Not quite sure in which order vs 2017 trying to resolve packages.
But my situation was following. In my VS2015 I had configured local and 3rd party source for nuget packages, newly installed version of 2017 loaded them too.
https://api.nuget.org/v3/index.json was first in list.
But vs2017 throwed an error that it can't restore .net core libraries from my another local repo.
After I unchecked all of them except https://api.nuget.org/v3/index.json, it had started to working normally.
I had this problem too, but not right now, this steps solved my problem: Choose Project -> Properties from the menu bar. In the Project properties window, under Configuration Properties -> General, make sure that Common Language Runtime Support is set to Common Language Runtime Support (/clr)
Simply opening the NuGet package manager and then the Visual Studio settings related to it - without changing anything - merely looking around, and when I closed out, the problem was gone.
This seems to be an intermittent issue that can come and go for no obvious reason.
None of the answers here worked for me so I'm posting what did work.
My errors were mostly the same as the original poster but I also had:
Error loading meta data for 'Microsoft.Extensions.FileProviders.Embedded.2.0.1'
hexadecimal value 0x1C invalid character
Every time I attempted to download a different nuget package or restore old packages I would see this error. I also saw the other errors such as:
type or namespace system could not be found
What worked for me:
opened the filepath that the error said the bad metadata was in, which for me was C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.extensions.fileproviders.embedded\2.0.1
Then, I put the contents of that folder into another folder I named "hiding".
Then, I went back to the nuget package manager and tried to install a package, hoping to have the SDK restored. IOt worked successfully, and all my other errors were gone as well, and the fresh new project runs as it should!
The problem for me occurred when running my Visual Studio as Admin with a separate user-- I had created a Git Repo with the source files in the user documents of my normal account. When I created a new solution in that folder the above errors occurred. Try creating your project in a different place and see if the error still occurs.
I was facing the same issue when I created a new project (.net Core 2.2) in VS2019.In my case there was an Azure package which was creating the problem.I uninstalled it and the project started working fine.
Run mentioned below command to uninstall the package.
Uninstall-Package Microsoft.VisualStudio.Azure.Containers.Tools.Targets -Version 1.7.10
I had the same problem. I cloned a github project and this error came. So I deleted the cloned project and then I cloned the project again and it worked fine.

Getting Error <location allowOverride="false"> while hosting WEB API 2 in Hostgator

I am using WEB API 2 its working in my local system,but when WEB API 2 run in Hostgator windows server its given me error below is my error screenshot
http://prntscr.com/bc5ihv
As I commented, I got similar problem while hosting web api on shared hosting.
The solution is to remove Microsoft.CodeDom.Providers.DotNetCompilerPlatform package and clean and build
You can deploy even without Roslyn with no change in code. Open NuGet Package Manager window and uninstall Microsoft.CodeDom.Providers.DotNetCompilerPlatform package and rebuild & republish. This uninstallation also removes CodeDom configuration from web.config file. This will solve your purpose. Basically this will not generate any csc.exe, vbc.exe files inside bin folder.
I got it from here

How to resolve errors with namespaces and references?

I just added an existing MVC project to VS 2012 that i downloaded from Codeplex. The problem is when i'm trying to build or run the project i get a lot of errors that VS can not find references and namespaces. If i open a new MVC project then i'm not getting this errors and everything runs fine. So it only occurs when i try to open an existing project.
Can someone help me with this please?
From the VS 2012 menu select Tools->Library Package Manager->Package Manager Settings. A window will appear. Check the checkbox labeled "Allow NuGet to download missing packages during build" under the Package Manager->General heading. Click the OK button to apply the setting.
Next in the Solution Explorer right-click the Solution node and select Enable NuGet Package Restore. Perform a Clean Solution and then a Build Solution. A .nuget folder should be downloaded into your solution and all compile errors related to missing references should be resolved.
This is what worked for me.

VB.NET Azure deployment has no /bin but has a nuget package

I've just published (via GitHub) a VB.NET Azure Website that works fine on local machines but not on Azure:
Compiler Error Message: BC30451: 'Newtonsoft' is not declared. It may
be inaccessible due to its protection level.
Dim category As Category = Newtonsoft.Json.JsonConvert.DeserializeObject(Of Category)(json)
The Newtonsoft.Json package is installed via NuGet: Newtonsoft.Json.5.0.5.
It's the only 3rd party dll in the project right now.
I used the Azure ftp access to browse to /site/wwwroot/ and noticed that there is no /bin directory.
Now, my .gitignore excludes [Bb]in and [Oo]bj folders, but it's the same .gitignore I've used successfully with c# projects and always assumed that Azure just fetches the missing nuget dlls from /packages.
This is my first VB.NET > GitHub > Azure Websites deployment. What have I missed?
edit: I can confirm that if I upload /Bin/Newtonsoft.Json.dll via Azure ftp the site works. Or at least it will until it's re-imaged...
Sounds like you've not enable "NuGet Package Restore".
By doing so this creates a .nuget folder at the root of your solution and a packages.config file in the application that the build process in Azure will pick up and load the required references from.
Right click on the solution and it should be an option in there.