-
Notifications
You must be signed in to change notification settings - Fork 593
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sample projects fail to properly build on Windows #1037
Comments
This is the extensive version of my comment here: #1024 (comment) |
Here's a patch file for the changes needed (with the example above). 0001-Proof-of-concept-to-get-the-sample-to-build-on-windo.patch.txt |
Just to give you a bit more background as to why we always pass Linux as the runtime identifier instead of Windows: If you are familiar with reference assemblies, you would know that they are the ones that get passed in to the compiler when building a project but not necessarily the ones that will be present at runtime. The runtime assembly, may have some changes in it as long as they are considered compatible with that reference assembly according to .NET Core's runtime, for example, it is fine to add a base class in the runtime specific assembly, even if the reference assembly didn't have it, this is accepted by the runtime. The reason why all of this is relevant, is because our "reference assembly" needs to be our Linux implementation, because if you have that as the reference assembly, the windows implementation does have some differences but all of them are compatible to the Linux one. The other way around is not true. So this means that if you compile against the windows implementation, and then try to run with the linux implementation, you will hit a bunch of runtime errors because the linux implementation is not API Compatible to the windows implementation. That is why across the repo, we have the ProjectReference to always be linux, so that we build against the linux implementation always, and so that at runtime we won't hit exceptions no matter if you run in Windows. All that said, this will all go away after we merge your great contribution of removing rid specific configurations, as we won't need to pass in rid as a property any longer. |
|
No questions are stupid :) it's better to ask them to understand better 👍 Given .NET Core basically builds into IL, IL is platform independent. The only way .NET Core would behave differently or compile differently for different platforms is if you intentionally make 2 assemblies that will do so, which is what we were doing in this repo. Also, this is not supported by MSBuild, since they only support cross-Framework targeting but not cross-RID targeting, so we had to add a bunch of logic directly here to suport that which is why a lot of things don't work as they should. Hopefully this will be over very soon 😄 when we merge your change. |
Closing this, as it is obsolete after #1038 has been merged. |
Describe the bug
Attempting to execute a sample on Windows (within Visual Studio) results in build errors.
This is irespective of the fact that many bindings don't work on Windows, just because the hardware is not there. This is about an ordinary Windows 10 x64 installation on a desktop computer.
Steps to reproduce
The build now fails:
The file
"C:\projects\iot4\artifacts\bin\System.Device.Gpio\Windows-Debug\netstandard2.0\ref\System.Device.Gpio.dll"
does not exist.Expected behavior
The above works and correctly builds the sample for windows.
Actual behavior
See above. An error happens.
Versions used
Latest master
Possible solutions
Workaround
The following works:
Replace the lines that include "System.Device.Gpio" in the project files (both the sample project and the binding project) with the following:
and add the following line (near the top):
This basically makes sure that, depending on the solution configuration, the correct reference is taken. Make sure the solution configuration now says "Windows-Debug" for all projects when the solution configuration is "Windows-Debug".
Better solution
The better solution would probably be to get rid of the different build configurations and just build one version of System.Device.GPIO that does all its operating-system dependent choices at runtime. (I belive there's a ticket for that already.)
The text was updated successfully, but these errors were encountered: