1

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.

Tore Østergaard
  • 4,362
  • 3
  • 27
  • 43
  • Seems when you build locally, also return the same warning? Are you using MSBuild task in your build pipeline, you could give a try with `/property:WarningLevel=0` MSBuild argument. Not sure if it will work with this kind of warning above. – PatrickLu-MSFT Nov 06 '17 at 11:25

4 Answers4

2

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>
Tore Østergaard
  • 4,362
  • 3
  • 27
  • 43
  • This answer worked for me, with a small variation. If you're using SDK-style projects, please refer to my answer in this post https://stackoverflow.com/a/62801507/31668 for the small change you need to make. – Eilon Jul 08 '20 at 18:38
  • Please also see my answer for additional empty targets that might need to be added to make this work. It could be that they are new additions since this question was originally asked/answered. – Eilon Jul 08 '20 at 21:21
1

We do nothing special to change the warning behavior in VSTS/TFS build comparing with local build through visual studio.

As far as I known, suppressing warnings with MSB prefix is still not possible. Refer to: Supress/Disable/Solve Visual Studio Build Warning

You could give a try with /property:WarningLevel=0through MSBuild argument. Not sure if it will work with this kind of warning above. If not, afraid there is no way to bypass it.

PatrickLu-MSFT
  • 49,478
  • 5
  • 35
  • 62
  • 2
    As far as I understand the above switch will disable all warnings and not only the specific one. That somehow ruin the point of being able to see the warnings that actually needs to be handled. – Tore Østergaard Nov 07 '17 at 09:23
  • @ToreØstergaard Yes this is the limitation. And afraid there is no way to only ignore a specific warning, this may be achieved through local VS. But definitely couldn't through vNext build. You could customize build log by using [logging command](https://github.com/Microsoft/vsts-tasks/blob/master/docs/authoring/commands.md) and invoke it through powershell, but could not suppress a generated warning message by build sever. – PatrickLu-MSFT Nov 07 '17 at 12:49
  • I found a workaround and added it as answer, but would like your comments on it Patrick. – Tore Østergaard Nov 09 '17 at 07:58
  • @ToreØstergaard Glad to here this, always better when you fix it yoursel :) – PatrickLu-MSFT Nov 09 '17 at 08:00
  • 1
    @ToreØstergaard Sorry not so familiar with xamarin project, seems like you are creating a customize target triggered when `&ServerAddress` = none after the error generated target . Then just prompt a message instead of warning in the target. The workaround looks feasible. – PatrickLu-MSFT Nov 09 '17 at 08:13
0

You should use /nowarn:VSX1000 per msbuild documentation

Rui Marinho
  • 1,692
  • 12
  • 20
0

I'd like to add a small variation of Tore Østergaard's answer in case you converted your CSPROJ to an SDK-style project (which iOS projects at this time are usually not, but you can make it work).

In an SDK-style project the "system" targets and props are imported via an SDK attribute at the top of the CSPROJ, like this:

<Project Sdk="MSBuild.Sdk.Extras">

  ... various project settings ...

</Project>

But if you try to use Tore Østergaard's answer, it won't work, because that answer's target overrides will be themselves overwritten by the SDK's targets (which are always imported last).

The workaround is to manually import the SDK targets and props so that you can control their order:

<Project>
  <!--
    The SDK is imported manually so that certain targets can be overridden (see bottom of file).
    Otherwise we could use Project Sdk="MSBuild.Sdk.Extras"
  -->
  <Import Project="Sdk.props" Sdk="MSBuild.Sdk.Extras" />

  ... various project settings ...

  <!-- See comment at top of file about manually importing SDK -->
  <Import Project="Sdk.targets" Sdk="MSBuild.Sdk.Extras" />
  <!--
    These targets must be imported last so that they override the SDK-provided targets.
    These override the Mac build agent command because they are not needed on CI.
  -->
  <Import Project="AvoidMacBuildWarning.targets" Condition=" '$(SkipMacBuild)' == 'true' " />
</Project>

Note: I also changed the condition to be a specific condition SkipMacBuild, but you can use whatever condition you want that makes sense for your build.

I also had to add an additional "empty target" to AvoidMacBuildWarning.targets to ensure they were also quieted. My full AvoidMacBuildWarning.targets looks like this:

<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <!-- Inspired by https://stackoverflow.com/a/47182083 from Tore Østergaard -->
  <Target Name="_SayHello">
    <Message Text="INFO: This would have been MSBuild warning VSX1000, but it has been ignored by importing this targets file." />
  </Target>
  <Target Name="_SayGoodbye">
  </Target>
  <Target Name="_DetectSdkLocations">
  </Target>
  <Target Name="_CollectBundleResources">
  </Target>
  <Target Name="_PackLibraryResources">
  </Target>
  <Target Name="CopyFilesToMacOutputDirectory">
  </Target>
    <Target Name="_VerifyBuildSignature">
  </Target>
    <Target Name="_VerifyXcodeVersion">
  </Target>
</Project>
Eilon
  • 25,582
  • 3
  • 84
  • 102