Unable to find package runtime.any.System.Reflection
Steps to reproduce
I am using Visual Studio 2017 to build my solution and then Publish the same using VS2017. I am building my code with x64 - Release configuration. It is being built successfully. While publishing the same for linux-64 Target Platform, it giving messages like following: Unable to find package runtime.any.System.Reflection : No packages exists with this id in source(s): Package source While running these objects on Linux(RHEL7) machine using dotnet command, the console returns immediately without executing. What could be the problem?
I am able to run the same code in Windows Machine. It is running successfully. No problem.
Expected behavior
It should publish the same successfully. It should run the same successfully on Linux machine.
Actual behavior
While executing application using dotnet command on Linux(RHEL7) machine, console returns back. No error, nothing.
Environment data
dotnet --info output:
@jkotas @steveharter Can you help on this???
the same for linux-64 Target Platform
This needs to be linux-x64. There is no platform called linux-64.
If you still see the problem, please share the project that hits the problem and exact steps needed to reproduce it.
@jkotas is absolutely right, you are using a non-existing rid linux-64 instead of the correct linux one linux-x64.
If this issue still repros with the correct rid, please comment and we can re-activate it.
@livarcocc @jkotas I m sorry. It was a typing mistake. Visual Studio provides dropdown to select target runtime with below mentioned options: 1)Portable 2)win-x86 3)win-x64 4)osx-x64 5)linux-x64
I m selecting linux-x64 as target runtime. and thus it is giving the error like I mentioned above. I also tried using Portable option but the result is same.
@jkotas I m not able to upload anything from my machine, so i m not able to share my project.
Also my machine can't access internet while building the code using VS2017.
What I think is while publishing the code for Linux-x64 target runtime, it requires some nuget packages which currently not available on my machine and as it can not access internet, it can not download it.
Is there a possibility that I provide internet access to my machine and it will work??
Is there a possibility that I provide internet access to my machine and it will work?
Yes, there is a very good chance that this would fix the problem.
A few question that may help us to understand the problem better:
- Does you project explicitly reference any additional NuGet packages except for the the default? If yes, is it possible to share the names and versions of these NuGet packages?
- What is the type of your project? (console app -
dotnet new console, ASP.NET -dotnet new web, etc.) - What is the .NET version that you project is targeting? Does your .csproj file has
<TargetFramework>netcoreapp2.0</TargetFramework>or<TargetFramework>netcoreapp2.1</TargetFramework>?
@jkotas, @livarcocc Internet access solved the issue for successful publishing the code.
For your information, I have used two following references explicitly:
<PackageReference Include="Syste.Data.SqlClient" Version="4.4.0"><PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="2.0.0">
My project type is console app.
My .NET Version is
I am able to publish the objects successfully. My publish profile is as following: Configuration : Release|x64 Target Framework : netcoreapp2.0 Deployment Mode : Self-contained Target Runtime : linux-x64
Now I am running published objects on linux machine and it is giving me following error: Unhandled Exception : System.IO.FileLoadException : Could not load file or assembly "System.Runtime.Extensions, Version=4.2.0.0, Culture=Nuetral". The located assembly's manifest definition does not match the assembly reference.
All the dlls and so files are exist on the same folder including System.Runtime.Extensions.dll (File Version = 4.6.24705.1).
There is a DOME.deps.json file which mentions dll file path such as "runtimes/linux-x64/lib/netcoreapp2.0/System.Runtime.Extensions.dll"
Is the above mentioned exception is because of this JSON file path ?? or Dll version mismatch??
You are likely running into bug https://github.com/dotnet/corefx/issues/23436 . You can try to add <PackageReference Include="Microsoft.NETCore.Targets" Version="2.0.0" /> to your .csproj file to workaround it (more details at https://github.com/dotnet/corefx/issues/23436#issuecomment-326296925).
@jkotas, @nguerrera @ericstj Do I have to add it in every project or just main project?
I did adding it in my main project. Then I publish and run the objects on Linux machine. output is it is returning console back immediately.
I also did publish my code using coomand dotnet publish ABC.dll -r rhel.7-x64. After running published objects on Linux machine, console returns back without running the application.
I tried sample .Net Core application without any dependecy, it works fine on Linux machine.
What to do now?
I also noticed one thing that while publishing, It puts all the dependent dls and so files in the same folder.
When I open deps.json file, it shows paths like
lib/netstandard2.0/Microsoft.EntityFrameworkCore.dll
runtimes/unix/lib/netstandard2.0/Microsoft.Win32.Registry.dll
Is this dependent dlls path needs to be corrected in deps.json file???
My publish folder does not contain any runtimes or lib folder.