如何抑制缺少 Mac 服务器的警告(警告 VSX1000)
How to suppress warnings for missing Mac Server (Warning VSX1000)
我们有许多 Xamarin iOS 项目是我们主要解决方案的一部分,因为我们需要确保它们作为门控签入的一部分进行编译。然而,我们的大多数开发人员并未使用 iOS,因此不会配置与 Mac 构建代理的连接。
在本地和我们的服务器上构建期间,我们看到此警告:
C:\Program Files (x86)\Microsoft Visual Studio17\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.
是否有某种方法可以配置这是否应该是警告,以便我们可以将其从 Visual Studio 中的 错误列表 中删除并且来自服务器的构建日志? 最好在项目中完成,这样每个人都可以设置一次。
我们正在使用最新的 Visual Studio 2017 和 TFS 2017 Update 2 并构建 vNext。
与通过 visual studio 进行的本地构建相比,我们没有做任何特别的事情来更改 VSTS/TFS 构建中的警告行为。
据我所知,仍然无法抑制带有 MSB 前缀的警告。参考:
您可以尝试使用 /property:WarningLevel=0
through MSBuild 参数。不确定它是否适用于上面的这种警告。不然怕没办法绕过
一个肮脏的解决方法是覆盖产生警告的目标 - 在我的情况下很好,因为我不需要它们。
在我们的 iOS 项目文件中,我有条件地(如果定义了服务器地址)导入一个目标文件 AvoidMacBuildWarning.target,它替换了一些目标。
部分项目文件:
...
</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>
你应该使用 /nowarn:VSX1000
每 msbuild documentation
我想添加一个 的小变体,以防您将 CSPROJ 转换为 SDK 样式的项目(此时 iOS 项目通常是 不是,但你可以让它工作。
在 SDK 风格的项目中,“系统”目标和道具是通过 CSPROJ 顶部的 SDK 属性导入的,如下所示:
<Project Sdk="MSBuild.Sdk.Extras">
... various project settings ...
</Project>
但是,如果您尝试使用 Tore Østergaard 的答案,它将不起作用,因为该答案的目标覆盖本身将被 SDK 的目标(始终导入 last ).
解决方法是手动导入 SDK 目标和道具,以便您可以控制它们的顺序:
<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>
注意:我还将条件更改为特定条件 SkipMacBuild
,但您可以使用任何对您的构建有意义的条件。
我还必须向 AvoidMacBuildWarning.targets
添加一个额外的“空目标”以确保它们也安静下来。我的完整 AvoidMacBuildWarning.targets
看起来像这样:
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!-- Inspired by 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>
我们有许多 Xamarin iOS 项目是我们主要解决方案的一部分,因为我们需要确保它们作为门控签入的一部分进行编译。然而,我们的大多数开发人员并未使用 iOS,因此不会配置与 Mac 构建代理的连接。
在本地和我们的服务器上构建期间,我们看到此警告:
C:\Program Files (x86)\Microsoft Visual Studio17\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.
是否有某种方法可以配置这是否应该是警告,以便我们可以将其从 Visual Studio 中的 错误列表 中删除并且来自服务器的构建日志? 最好在项目中完成,这样每个人都可以设置一次。
我们正在使用最新的 Visual Studio 2017 和 TFS 2017 Update 2 并构建 vNext。
与通过 visual studio 进行的本地构建相比,我们没有做任何特别的事情来更改 VSTS/TFS 构建中的警告行为。
据我所知,仍然无法抑制带有 MSB 前缀的警告。参考:
您可以尝试使用 /property:WarningLevel=0
through MSBuild 参数。不确定它是否适用于上面的这种警告。不然怕没办法绕过
一个肮脏的解决方法是覆盖产生警告的目标 - 在我的情况下很好,因为我不需要它们。
在我们的 iOS 项目文件中,我有条件地(如果定义了服务器地址)导入一个目标文件 AvoidMacBuildWarning.target,它替换了一些目标。
部分项目文件:
...
</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>
你应该使用 /nowarn:VSX1000
每 msbuild documentation
我想添加一个
在 SDK 风格的项目中,“系统”目标和道具是通过 CSPROJ 顶部的 SDK 属性导入的,如下所示:
<Project Sdk="MSBuild.Sdk.Extras">
... various project settings ...
</Project>
但是,如果您尝试使用 Tore Østergaard 的答案,它将不起作用,因为该答案的目标覆盖本身将被 SDK 的目标(始终导入 last ).
解决方法是手动导入 SDK 目标和道具,以便您可以控制它们的顺序:
<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>
注意:我还将条件更改为特定条件 SkipMacBuild
,但您可以使用任何对您的构建有意义的条件。
我还必须向 AvoidMacBuildWarning.targets
添加一个额外的“空目标”以确保它们也安静下来。我的完整 AvoidMacBuildWarning.targets
看起来像这样:
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!-- Inspired by 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>