Reputation: 1423
I have a .NET Core console app and want to make it a self-contained app that targets Windows and Mac OS X.
The way to do it, according to a tutorial that I'm following, is to edit the project file.
To make it a self-contained Windows only app, I add this line.
<RuntimeIdentifiers>win10-x64</RuntimeIdentifiers>
This works as expected, and I can publish the app and everything works. Now, to target Mac OS X as well as Windows, according to the tutorial, you need to change that line like this.
<RuntimeIdentifiers>win10-x64;osx.10.12-x64</RuntimeIdentifiers>
However, when I put that in and try to save the changes to the project file, I run into the following error(s).
Related to Debug folder:
The "HasTrailingSlash" function only accepts a scalar value, but its argument "$(OutputPath)" evaluates to "bin\Debug\netcoreapp2.0\win10-x64;osx.10.12-x64\" which is not a scalar value. C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets
Related to Release folder:
The "HasTrailingSlash" function only accepts a scalar value, but its argument "$(OutputPath)" evaluates to "bin\Release\netcoreapp2.0\win10-x64;osx.10.12-x64\" which is not a scalar value. C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets
The project file is still saved, once I get away from all the warnings. They appear several times. Specifically, 4 warnings about debug path and 2 about release path (number of save attempts?).
When I close the solution and then open it again, this particular project refuses to load. It just sits in Solution Explorer as a project that's not loaded.
If I try to reload it I get a nice little red, critical error icon along with the same message.
Why is this happening, what seems to be the problem? Please advise, what's the appropriate way to target both Windows and Mac OS X for self-contained deployment on a Windows machine?
Is editing the project file still a valid approach? The tutorial I am following was released in August 2017 by a "software architect and developer with a passion for the cloud". He did comment on his approach of editing the project file, calling the current tooling "wonky".
<RuntimeIdentifiers>win10-x64;osx.10.12-x64</RuntimeIdentifiers>
This is not what I had typed in.
Instead, this is what I had in my code. Notice the singular form.
<RuntimeIdentifier>win10-x64;osx.10.12-x64</RuntimeIdentifier>
The problem lies in that I did not pay attention, nor did I type it in manually. I used code auto-completion (IntelliSense) and just tabbed through these tags.
Upvotes: 3
Views: 2376
Reputation: 1423
For only one runtime identifier (RID), you can use either the singular or the plural form of the XML runtime identifier tag.
<RuntimeIdentifier>win10-x64</RuntimeIdentifier>
OR
<RuntimeIdentifiers>win10-x64</RuntimeIdentifiers>
For more than one RID, you have to use the plural form of the XML runtime identifier tag.
<RuntimeIdentifiers>win10-x64;osx.10.12-x64</RuntimeIdentifiers>
Upvotes: 4