I have been trying to configure a project level nuget.config file as per the various documentation and instructions I found online from MSDN and other sources. I have visual studio 2017 community edition installed. I can't seem to find nuget.exe so I can configure the local nuget.config file with my settings as well as tell nuget to use the new project level nuget.config.
https://learn.microsoft.com/en-us/nuget/reference/nuget-config-file#config-section
https://learn.microsoft.com/en-us/nuget/consume-packages/configuring-nuget-behavior
I launched developer command prompt in administrator mode and when I type NUGET to access nuget.exe, I got error that command not found.
I am trying to figure out where I need to be so when I run the following command nuget can resolve:
nuget config -set repositoryPath=c:\packages -configfile .\myApp\NuGet.Config
I get:
'nuget' is not recognized as an internal or external command, operable
program or batch file.
I tried searching for nuget.exe everywhere on my machine, but can't seem to find it.
Do I need to re-download and install the exe? It seems that it is already built-in to visual studio and I would ideally like to leverage that same version installed.
Would appreciate any input, ideas or help.
Many Thanks!!!!
Found the answer.While the package manager console is available and comes with visual studio 2017. Nuget.exe is not included only the dlls for nuget are. That is clearly outlined in the downloads page of NUGET.
https://www.nuget.org/downloads
The last windows update has broken our whole build chain and I am a little at a loss at what causes it.
I have a legacy project that is a VS 2017 solution with a significant number of projects (winform, couple web based, some Webapi only).
Locally things work perfectly. I can just build them.
On the server, the proejct has started to fail, and the error is:
C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\Microsoft\NuGet\15.0\Microsoft.NuGet.targets(186,5): Error : Your project file doesn't list 'win' as a "RuntimeIdentifier". You should add 'win' to the "RuntimeIdentifiers" property in your project file and then re-run NuGet restore.
C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\Microsoft\NuGet\15.0\Microsoft.NuGet.targets(186,5): Error : Your project file doesn't list 'win' as a "RuntimeIdentifier". You should add 'win' to the "RuntimeIdentifiers" property in your project file and then re-run NuGet restore.
C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\Microsoft\NuGet\15.0\Microsoft.NuGet.targets(186,5): Error : Your project file doesn't list 'win' as a "RuntimeIdentifier". You should add 'win' to the "RuntimeIdentifiers" property in your project file and then re-run NuGet restore.
Process 'msbuild.exe' exited with code '1'.
I have added
<RuntimeIdentifiers>win</RuntimeIdentifiers>
To a number of projects. No change. I am at a loss, because the error message does not even tell me which project.
At some point before attempting to build, you need to delete the obj folder.
More than one person showed this to solve the problem.
https://developercommunity.visualstudio.com/content/problem/312180/projects-fail-to-build-in-1580-due-to-errors-from.html
Although #SeƱor CMasMas's answer has helped me in the past, I'm now finding (since installing the .NET Core SDK v2.2 - I don't know if that's related though) that I also need to close and reopen Visual Studio. So for me the recipe is:
Clean solution
Delete obj folders
Delete the .vs folder (optional, if you get red lines but it builds OK)
Close and reopen Visual Studio
Then build
Add this: <RuntimeIdentifier>win</RuntimeIdentifier>
to your project file, for example after element TargetFrameworkVersion. Make sure the element name is singular. RuntimeIdentifiers on the other hand is used in the new csproj format
Or you just can run in the root directory of your project the script in PowerShell that you should run as administrator.
Get-ChildItem .\ -include bin,obj -Recurse | foreach { remove-item $_.fullname -Force -Recurse }
this script will delete all obj and bin folders
I have come across same error in Vs 2019 (16.8.6), following steps resolved my problem.
Close visual studio (other visual studio instances may remain)
Delete all bin and obj folders in all projects in the solution
Reopen solution and Build
Note that if bin folders exist, deleting only obj folders doesn't work, you need to delete bin folders too.
Had this problem in projects using packageReference when manually restoring packages by running
NuGet.exe restore my.sln
as part of a TeamCity build (so might be related nf313743's answer https://stackoverflow.com/a/60951212/128384) and then building projects using msbuild.
This would result in the following error when msbuild begins dealing with the PackageReference:
[ResolveNuGetPackageAssets] C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\Microsoft\NuGet\15.0\Microsoft.NuGet.targets(186, 5):
Your project file doesn't list 'win-x86' as a "RuntimeIdentifier". You should add 'win-x86' to the "RuntimeIdentifiers" property in your project file and then re-run NuGet restore.
Deleting obj directories etc doesn't work here because they get added by the restore step; adding a RuntimeIdentifier might, but building the exact same on a VS2017 commandline works fine so clearly the difference is in how TeamCity sets up the environment.
The culprit could be found in the output of the first call:
NuGet.exe restore my.sln -NonInteractive
MSBuild auto-detection: using msbuild version '16.10.2.30804'
from 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\bin'.
it uses msbuild from the VS2019 installation whereas the project is being built by VS2017, so somewhere in mixing those there is an incompatibility which is not unexpected. Anyway, the key is likely that TeamCity doesn't setup a complete environment like the VS2017 commandline does and the NuGet documentation says
By default the MSBuild in your path is picked,
otherwise it defaults to the highest installed version of MSBuild.
so that's why it uses the VS2019 one. Solution is to manually pass -MsBuildPath to NuGet and set it to what corresponds to the selected buildtools in teamCity, in this case:
NuGet.exe -msBuildPath "%MSBuildTools15.0_x86_Path%" restore my.sln
(and it turns out teamCity itself is also plagued by this in its own NuGet step: How to set the MSBuild verision for TeamCity NuGet Installer?)
I have a similar case. I try to build a solution via msbuild without installing Visual Studio 2017, just install the latest version of vs 2017 build tools. Here are my steps:
dotnet restore a.sln
(There are some .Net Standard Library project in this solution, the others are .NET 4.7.2 projects).
call msbuild.exe to build this solution.
I got the error of "missing RuntimeIdentifier".
Your project file doesn't list 'win' as a "RuntimeIdentifier". You should add 'win' to the "RuntimeIdentifiers" property in your project file and then re-run NuGet restore.
It seems an issue in the old version of Nuget. Please refer here. Finally, I resolved it via restore packages with the latest Nuget (v5.0.2).
the steps:
Delete obj and bin folders
nuget.exe restore a.sln
call msbuild.exe
I had a similar problem. My error was
error : Your project file doesn't list 'win10' as a
"RuntimeIdentifier". You should add 'win10' to the
"RuntimeIdentifiers" property in your project file and then re-run
NuGet restore.
Well, it turned out I just had to change by build target from "Any CPU" to something else (x64 for example)...
you got to figure out which projects in your solution trigger this error. you can find this if you look at the error panel.
go to that projects locations and delete both the bin and the obj folders.
then rebuild.
should be alright
I had this same issue toggling across vstools build chains (VS2017/VS2019) - here is what fixed it for me - brute force clean via rimraf
Your project file doesn't list 'win' as a "RuntimeIdentifier". You should add 'win' to the "RuntimeIdentifiers" proper ty in your project file and then re-run NuGet restore
Remove Intermediary Build Output Artifacts
rimraf *\obj\**
The RuntimeIdentifier should look something more like what's described here: https://learn.microsoft.com/en-us/dotnet/core/rid-catalog.
Given this appears to build just find locally, I'd diff the .csproj on your local machine against the one on your build server. Something tells me, they are not identical.
FWIW, Line 186 in the noted Microsoft.NuGet.targets file, is running the ResolveNuGetPackageAssets task, and you can see the RuntimeIdentifier argument being passed as the NuGetRuntimeIdentifier property. You could probably backtrace that in your working build's diagnostic log to see how it's being assigned.
But given this works on one box, and not on another, I'd just dbl check your project files and verify that the RuntimeIdentifier tag identical on both systems.
Sincerely,
So I was seeing the same error message as this on our on premises DevOps build server, but it built fine locally in Visual Studio as well as via the msbuild on the command line.
I checked and I DID have the <RuntimeIdentifiers> defined in my project file and clearing out the obj and bin folders on the server did NOT fix it for me.
Our issue was we had the < RunTimeIdentifiers> tag showing up MULTIPLE times in the build section,(probably from a bad merge at some point in the past). After removing the duplicate tags, DevOps successfully built the project.
I was googling for hours and never stumbled on this being the cause of the issue for anyone else. Hopefully this saves someone else some time in the future if they have the same problem.
For me, it was as simple as compiling a Windows IoT App with x86 platform instead of ARM.
In my case, this was happening on an Azure build.
I was able to resolve it by forcing the build to use Visual Studio 2019 tools.
I modified our build.cake file so that the MSBuild steps included the UseToolVersion for VS 2019 like this:
MSBuild(_solutionFile, settings => settings.SetConfiguration(_configuration)
.UseToolVersion(MSBuildToolVersion.VS2019));
The only thing that worked for me was to delete ALL project files and download them again from the version control. Then the problem disappeared.
If you are targeting Azure Service Fabric or other 64-bit environment, check that you have a consistent <PlatformTarget>x64</PlatformTarget> in all configurations defined in the CSPROJ file. In my case it built just fine locally but failed on the CI server because one of the many configurations had <PlatformTarget>AnyCPU</PlatformTarget>.
I was receiving the same error as the original poster, with Msbuild v15.9.21
Your project file doesn't list 'win' as a "RuntimeIdentifier". You should add 'win' to the "RuntimeIdentifiers" property in your project file and then re-run NuGet restore
My projects are .net Framework v4.6.2. The projects build fine locally using VS 2017, but failed when building on TeamCity Enterprise 10.0.5. I had recently converted my projects from .package to PackageReference - this causing the build to fail.
My solution was to add a new build step to explictly restore the solution's nuget packages before building the solution. It seems that before converting the projects to PackageReference this was being done on the build step implicitly.
I always get this error in the Azure pipeline. So far I have noticed the following fixed for me in various occasions:
1. do not commit the .suo file - if so, delete and recommit
2. do not commit the bin or obj folders - if so, delete and recommit
3. if there is a new project added, set the project dependency on the solution properties - save and commit the .sln file
I had same issue with one of the unit test project failing to compile after I upgraded to VS to 15.9.27 and the solution to delete the obj folder worked for me
A simple nuget restore before calling MSBuild worked for me. I have projects targeting .NET Framework 4.7.2 (not SDK Style, legacy style) which I migrated from packages.config syntax.
I experienced this issue with a MSBUILD project that I've added into a solution of VS2015 and VS2019, that project was compiled with VS2010. I just excluded it from solution and compiled it with VS2010, including the .DLL file into other projects that work with VS2015 and VS2019.
To projects mult-target fmk
Add this to your project file, for example:
<PropertyGroup>
<RuntimeIdentifier>ubuntu.16.04-x64</RuntimeIdentifier>
</PropertyGroup>
or
<PropertyGroup>
<RuntimeIdentifier>win</RuntimeIdentifier>
</PropertyGroup>
I'm using VS 2019 (16.11.17). I was working in 2022 on a different branch.
I tried all of these solutions and none worked, until I deleted the solution folder and cloned fresh.
I am trying to run NServiceBus with AspNetCore2 on visual studio 2017. While I install NServiceBus(Version 7.0.0-beta0001) and NServiceBus.Host(Version 8.0.0-beta0001) through nuget, it says package installed successfully.
However, when i try to check installed dll's and exe files of NServiceBus within bin/debug folder, it's not there.
Quick observations i made are, NServiceBus (version 7.0...) is installed correctly whereas NServiceBus.Host (version 8.0....) is showing a warning message under nuget folder in visual studio:
Package 'NServiceBus.Host 8.0.0-beta0001' was restored using '.NETFramework,Version=v4.6.1' instead of the project target framework '.NETCoreApp,Version=v2.0'. This package may not be fully compatible with your project.
Please help me to resolve this issue or point me to correct question if it's already been answered (which i could not find in SO)
NServiceBus.Host is being phased out for the reasons specified here. Long story short, in .NET Core it does not add much of a value and has more cons.
You can however, still run the NServiceBus process in a console app. Have a look at the self-hosting sample here.
For the life of me I can't get unit testing working in Visual Studio 2017 from the new msbuild-based netcoreapp1.0 xunit project template.
The requirement is for unit tests to work both inside Visual Studio (for the devs) and from dotnet test on the CLI for the automated build process however, I can't get either working consistently.
Here is what I have tried:
In an existing solution, create a new project and select .NET Core > xUnit Test Project.
Build project from Visual Studio, default test appears and runs successfully, now run dotnet test from powershell prompt, get:
> dotnet test
Test run for D:\...\bin\Debug\netcoreapp1.0\MyProj.dll(.NETCoreApp,Version=v1.0)
dotnet exec needs a managed .dll or .exe extension. The application specified was 'C:\Program'
Or dotnet test with csproj file:
> dotnet test MyProject.csproj
(same error as above)
> dotnet test ..\MySolution.sln
Couldn't find a project to run test from. Ensure a project exists in D:\...
Or pass the path to the project
If I add the xunit.runner.console or xunit.runner.msbuild nuget packages, it stops the unit tests working from inside Visual Studio.
How do I get both working at the same time?
Thanks!
The bug you're hitting is present in Preview 3 and fixed in Preview 4. They didn't escape the command line when executing it, and since dotnet.exe is installed into C:\Program Files\dotnet by default, it always fails.
If you want to continue to use Preview 3, the simplest work-around is to edit your system PATH environment variable, and replace C:\Program Files\dotnet with C:\Progra~1\dotnet.
I know this isn't a very good answer, but dotnet-test-xunit only support project.json files. VS 2017 forces you to switch to csproj files.
I found this on xunit twitter feed:
If you're trying use #xunit in VS2017 RC w/ .NET Core, remove dotnet-test-xunit and use xunit.runner.visualstudio 2.2 beta 4 instead.
With the latest RC.3 I was having issues with the tests not being discovered, and found out that when you run the built-in Test Explorer it says in the output that Microsoft.DotNet.InternalAbstractions 1.0.0 is missing. This was also issue in the previous versions of .NET Core, and the solution is the same, install the package from Nuget.
I have an ASP.Net project that's using the ClearScript.V8 library which relies on the Visual Studio 2012 C++ Redistributable to work. I'm faced with the prospect of having to install this on 50+ machines and I'm curious if I can get TFS to do it for me.
I realize this straddles somewhere between Stack Overflow and Server Fault so I'm asking on both sites.
Assuming that the binaries for ClearScript.V8 is included in your project (either as files copied to the bin folder or as a NuGet package) you should be able to also include the necessary Visual C++ redistributables files as binary files in your project. They will then be stored in TFS.
If you prefer NuGet packages you can to set up a local NuGet repository within your organization and create a NuGet package with the necessary DLLs which you then can reference from your project. If NuGet package restore is configured for your solution the package will be downloaded before the solution is built. In VS2012 you will have to make some customizations for this to happen on a Team Foundation Build server.
If you are unsure which DLLs you need to include you can use a tool like Dependency Walker to discover which DLL's are required, or you can debug the application and see which DLLs are loaded in the modules window. Microsoft has some information which DLLs to redistribute.
If you are having problems with conflicting versions of a redistributable DLL getting loaded you can create a side-by-side manifest to ensure that the correct DLL version is loaded into your application. However, as your application is hosted within ASP.NET this is somewhat tricky because w3wp.exe is executed by IIS outside your direct control. You will have to create an activation context to configure the manifest used by your application.
If you need to have things installed on your server for a build I would recommend that you use Chocolatey.
chocolatey.org/
This is an implementation of NuGet in PowerShell to explicitly solve the issue that you face. You can create a powershell file that installs all of the bits that you need and easily include it as a pre build step in TFS 2013. You can use the PowerShell activity from the TFS Community Build Tools to call the PowerShell in TFS 2010 or 2012.