Search code examples
xamarin.iosvisual-studio-2017tfsbuild

How to suppress warnings for missing Mac Server (Warning VSX1000)


We have a number of Xamarin iOS projects that are part of our main solution since we need to ensure that they compile as part of the gated check-in. However most of our developers are not using iOS and hence do not configure a connection to a Mac build agent.

During build locally and on our servers, we see this warning:

C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Xamarin\iOS\Xamarin.iOS.Windows.After.targets(63,5): Warning VSX1000: No Address and User has been specified in order to establish a connection to a Mac Server, so only the main assembly was compiled for project 'MyProject.iOS'. Connect to a Mac Server and try again to build the full application.

Is there some way of configuring whether this should be a warning, so that we can remove it from the Error List in Visual Studio and the build log from the server? Preferably it should be done in the projects so it could be set once for everyone.

We are using latest Visual Studio 2017 and TFS 2017 Update 2 and build vNext.


Solution

  • A dirty workaround is to override the targets that produce the warning - in my case that's fine as I don't need them.

    In our iOS project files I conditionally (if a server address is defined) import a target file, AvoidMacBuildWarning.target, that replaces a number of targets.

    Parts of the project file:

    ...
    </ItemGroup>
    <Import Project="$(MSBuildExtensionsPath)\Xamarin\iOS\Xamarin.iOS.CSharp.targets"/>
    <Import Project="AvoidMacBuildWarning.target" Condition=" '$(ServerAddress)' == '' " />
    <ItemGroup>
    ...
    

    AvoidMacBuildWarning.target:

    <?xml version="1.0" encoding="utf-8"?>
    <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
      <Target Name="_SayHello">
        <Message Text="Warning (demoted to message) VSX1000: No Address and User has been specified in order to establish a connection to a Mac Server, so only the main assembly was compiled for project 'MediumService.iOS'. Connect to a Mac Server and try again to build the full application." />
      </Target>
      <Target Name="_SayGoodbye">
      </Target>
      <Target Name="_DetectSdkLocations">
      </Target>
      <Target Name="_CollectBundleResources">
      </Target>
      <Target Name="_PackLibraryResources">
      </Target>
      <Target Name="CopyFilesToMacOutputDirectory">
      </Target>
    </Project>