[Mono-dev] Mono.Posix Cross Compiling
curylod at asme.org
Tue Jan 6 14:54:19 UTC 2015
You have to use conditional compilation for the code that uses the conditional reference, in this case Mono.Posix. The reference appears with a warning in Visual Studio and you get a compiler warning, “The referenced component ‘Mono.Posix’ could not be found” but this is to be expected on Windows/.NET. This may be an annoyance, but it allows developers to be productive developers on either platform, so I consider this to be a functional solution.
I created an example here on github: https://github.com/ninjarobot/MonoConditionalReference
This builds fine on Xamarin Studio on OS X and Visual Studio on Windows, although given the conditional compilation, the resulting assembly is different. We take this approach in my organization so that some developers can work on Windows with Visual Studio and other developers work entirely on mono (our target platform).
On Jan 6, 2015, at 8:39 AM, Edward Ned Harvey (mono) <edward.harvey.mono at clevertrove.com> wrote:
>> From: mono-devel-list-bounces at lists.ximian.com [mailto:mono-devel-list-
>> bounces at lists.ximian.com] On Behalf Of David Curylo
>> If you edit the .csproj file, you can have a platform-specific reference
>> Mono.Posix like this:
>> <Reference Include="Mono.Posix" Condition=" '$(OS)' != 'Windows_NT' " />
> I've never gotten this to work before. Moments ago, I pasted the above into a test project, just to see if the above would work - and it didn't. The reference is still present, and still broken, if I open a project with the above line in Visual Studio. Fortunately as long as you don't use anything from the missing assembly, the project still builds, so in some cases you can ignore the broken reference by using [Conditional] and/or #if to wrap around all the things that actually use something from that assembly...
> The workaround I've always settled on was to make multiple versions of the .sln and .csproj files if I need different assemblies referenced on .Net and mono. (Which is usually the case, because of NUnit and Mono.Security, which I use a lot.) If you find a way to make the conditional reference functional, please post. I'd love to know.
More information about the Mono-devel-list