We (me and three other people) will make an ASP.NET MVC application and use GitHub for version control. We've added some NuGet packages like Unity.MVC5.
Person one has commit and sync the project to the master branch. He's got no problems. The other three people sync the branch but they got problems with the NuGet libaries. See errors below:
Error: This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is ..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.0\build\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props.
Error: Metadata file D:\...\MarkeOnlineWebsite\MarkeOnline.Website\bin\MarkeOnline.Website.dll could not be found
Warning: The referenced component ... could not be found.
Update: I've also added this .gitignore file.
How could we solve this problem?
Related
I have a package config file for a project this
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Stylesoft.Common.Dev" version="1.0.1.0" targetFramework="net461" />
</packages>
And the package dll is referenced like this in csproj file
<Reference Include="Stylesoft.Common.Dev, Version=1.0.1.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\..\..\..\..\SharedPackages\Stylesoft.Common.Dev.1.0.1.0\lib\net40\Stylesoft.Common.Dev.dll</HintPath>
</Reference>
Earlier this used to work because nuget used to restore the package in this folder Stylesoft.Common.Dev.1.0.1.0 but I don't know what was changed but now nuget skip the revision number of version, now it creates folder with name Stylesoft.Common.Dev.1.0.1 skipping last zero and so I get compile error, because the project tries to check dll in this path
..\..\..\..\..\SharedPackages\Stylesoft.Common.Dev.1.0.1.0\lib\net40\Stylesoft.Common.Dev.dll
I am not able to figure out what was changed and how to make it restore package in the same folder structure as earlier
Any help would be appreciated!
I was suffering the same problem. The cause will either be that the nuget.exe version has been updated and now downloading packages excluding the revision in the path, or that a change has occurred where the packages are hosted. Not sure which for myself as this happened when migrating source from TFS to Azure DevOps. So the build pipeline is different and the packages are on a new feed.
I feel the best solution is to make the projects in Visual Studio work locally the same way the server build expects them to. So as it is looking for packages in folders excluding the revision number in their name, that's where they should be.
So the fix is to reinstall the packages using the same feed and nuget client. The visual studio package manager should install the packages to the correct location. So you can either ensure that you have the correct versions, or just hope it will be ok and continue with the following:
Delete all of the packages from the packages folder (hopefully all your projects use the same folder otherwise this may be laborious).
Clear your nuget package cache from visual studio (there's a button to do this under Tools -> Options -> Nuget Package Manager)
In visual studio, open the nuget package manager console.
Run 'Update-Package -reinstall'
It may take some time depending on how many packages and projects you have, but this will hopefully ensure your project reference hint paths will match the packages' installed locations.
I have a Xamarin Forms Project - the Android project targets API 28 (Pie) and uses packages.config for the nuget references. All of the packages have a targetFramework="monoandroid90". The project compiles and runs correctly.
I want to migrate to using PackageReference, so I use the Migrate packages.config to PackageReference option.
After this completes I try to build the project and receive an error regarding a missing package:
Xamarin.Android.Support.Annotations.28.0.0.1
Looking in the packages folder, I can see that none of the Xamarin.Android.Support packages have been downloaded and I can't get them to download - even by reinstalling the package.
I also noticed that the csproj file reference monoandroid81 for all the nugets, even though the packages.config used monoandroid90
Has anyone had a similar difficulty after migrating?
I have Solution A which has a .NET Core 1.1 class library project. In the Package properties I filled all NuGet fields and selected to create the NuGet upon successful build. This project builds just fine and the NUPKG is created. BTW How can I automatically copy the generated NUPKG to a local directory (my own repository)?
Then I have Solution B which is an ASP.NET Core 1.1 web application. In it I browse to my local repository (where I have manually copied the NUPKG built by Solution A) and install my SolutionA.MyPackage into the web application. VS.2017 says it was successful at installing it. I see it listed in the project's NuGet dependencies.
However, when I try to use ANY of the objects defined in that NuGet package I get a red highlight saying it is not found as if there was no NuGet or assembly reference to that DLL but there is!
What is causing this Visual Studio generated Nuget package to be installed and yet act as if it has not even been referenced?
UPDATE - CSPROJ TARGET
As for copying to my local repository, I added this to CSPROJ but it was not working (somebody had suggested it as I put it). I finally figured out why it did not work, the ItemGroup must be inside the Task.
<Target Name="CopyPackage" AfterTargets="GenerateNuspec">
<ItemGroup>
<MyPackageFiles Include="bin\Release\PackageId.*.nupkg" />
</ItemGroup>
<Copy SourceFiles="#(MyPackageFiles)" DestinationFolder="D:\My Repository\MyNugget\Publish" />
</Target>
UPDATE NuGet Inspection
I opened the NUPKG with NuGet Package Explorer and it shows this more or less:
content\
Properties\
launchSettings.json
Views\
Shared\
rest of my stuff here
contentFiles\
any\
netcoreapp1.1\
Properties\
launchSettings.json
Views\
Shared\
rest of my stuff here
lib\
netcoreapp1.1 (.NEtCoreApp, Version=v1.1)
MyPackage.dll
UPDATE 3
Since NuGet seems to have stopped working (used to work well earlier) I opted for using an Assembly Reference rather than a NuGet (for now). In this situation something odd happens, when coding I can reference ALL the objects in the referenced assembly (former NuGet) and therefore no compilation errors on the main project BUT when I then run the web application I get an internal error because it says
FileNotFoundException: Could not load file or assembly
'MyPackage, Version=0.0.3.0, Culture=neutral, PublicKeyToken=null'.
The system cannot find the file specified.
Unknown location
Which is strange because in the Solution Explorer I see the assembly reference and when I click on it (main application) I can navigate to all the objects that I have defined in that assembly. Why it cannot find it anymore?
It is working again (as it was before!). Today I could open the solutions but when I tried to download an extension (Tools | Extensions) I got an error message about an Access Denied or something like that. It has happened before since I installed to VS.2017.
Of all the Visual Studios I have used since 2002 this has been the most unstable! (and I have update 15.2).
When I saw this error happening again I knew how to get rid of it and thought, "hey, maybe that is what is keeping the NuGet package to be installed but not found or the problem with a direct assembly reference".
So I went to my C:\Users\AppData\USER\Local\Microsoft\VisualStudio\15.2* folder and removed it completely.
After that I the ACCESS DENIED issue went away with the side effect that I had to reinstall all extensions again. I attempted again to install my own NuGet, it did so successfully and as expected (was not happening during the long glitch) the objects were found and the web application worked again.
ASP.NET 4.5.1 or 4.5.2
Updating Nuget package MicrosoftAspNet.Identity.EntityFramework from version 2.2.1 to version 3.0.0-rc1-final
I get the following error:
Failed to add reference. The package 'Microsoft.AspNet.Identity.EntityFramework' tried to add a framework reference to 'System.Runtime' which was not found in the GAC. This is possibly a bug in the package. Please contact the package
owners for assistance.
I had a similar issue with another package.
I "solved" it adding a manually reference to missed library, updating the package and then removing the reference added manually:
On your project go to References -> Add Reference... and then click on Browse...
On my installation (Windows 10), your file is located on: C:\Windows\Microsoft.NET\assembly\GAC_MSIL\System.Runtime\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Runtime.dll
Add, update and then remove.
I know, it is not a solution, but it will allow you continue working until get a real solution.
I had the same issue, but adding the MySQL package to my project.
The way that i solved was just very closely to the answer given by Sebastián Guerrero.
So i will be adding a manually reference to that missed library (system.runtime) and than installed the MySQL package and it works perfectly.
ATTENTION: I only unnistall the system.runtime package after installing the MySQL.
References -> Add Reference... and then click on Browse...
On my installation (Windows 10), your file is located on:
C:\Windows\Microsoft.NET\assembly\GAC_MSIL\System.Runtime\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Runtime.dll
I had the same issue when running Install-Package Microsoft.Azure.Management.Fluent on .NET framework 4.5.2
Solved the issue with the following steps:
Installed Microsoft.Rest.ClientRuntime latest version from Nuget.
After that, installed latest version of Microsoft.Azure.Management.Fluent from Nuget.
I had this problem when I opened the project after a while.
The problem was it was originally built with Microsoft.Net.Compilers.2.4.0 and I was on 3.3.1.
The project strangely added two required Imports to the .csproj file, one for the 2.4.0 compiler,and a duplicate for the 3.3.1 version. I just needed to:
Right click on the project file
Unload the project
Edit the csproj file
Remove the 2.4.0 references (was also a reference in an Error element)
Close file
Right click on project, reload file.
Rebuild All
I want to configure bundling to my new project. I have configured my project with TFS online but I cannot add any packages via nuget and always get this error.
The item F:\Project\MOC\packages\WebGrease.1.5.2\lib\WebGrease.dll could not be found in your workspace, or you do not have permission to access it.
The item F:\Project\MOC\packages\WebGrease.1.5.2\tools\install.ps1 could not be found in your workspace, or you do not have permission to access it.
The item F:\Project\MOC\packages\WebGrease.1.5.2\tools\uninstall.ps1 could not be found in your workspace, or you do not have permission to access it.
This maybe a nuget bug with older version. More details ,please refer the thread from GitHub: Install package fails when solution/project is bound to TFS source control
The bug is during uninstalling packages, nuget will delete package
files from TFS, but if user set disableSourceControllntegration to
true, package files are not added to TFS workplace during installing,
so TFS can't find those files during uninstalling,
The fix is to check disableSourceControlIntegration before deleting
package files from TFS.
Source Link: TFS Error "[file]not be found in your
workspace...."
Also suggest you to update your nuget version to latest and try again.