Skip to content

Commit

Permalink
[remote] Explicitly import .mobile.props file
Browse files Browse the repository at this point in the history
The .mobile.props file is a file created and written by the mobile VS extension to store property values that needs to be read early enough in the build chain, as in design time builds, and that can't be set by CPS because of a limitation in the project system. See more information here: xamarin/XamarinVS#13606

Initially it was named .user.env file and then was renamed in another PR as part of a feedback from the project system team. See more information here: xamarin/XamarinVS#13628

Because this file was saved in the intermediate output path, it was meant to be imported automatically by MSBuild, however we recently detected that this was not happening reliably. Because of this, some things like C# Hot Reload for iOS stopped working because Roslyn was reading incorrect values from the Design Time Builds.

For that reason and to avoid relying on the project system, we decided to import this file explicitly (and remove old .user.env import), so the values in the file are always available and the dependent properties are calculated correctly and available for all the consumers (including Roslyn).

This should fix the following bugs:

https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1822041

https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1851677
  • Loading branch information
mauroa committed Aug 14, 2023
1 parent 2489540 commit 654172d
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions dotnet/targets/Xamarin.Shared.Sdk.props
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,16 @@

<Import Project="Xamarin.Shared.Sdk.TargetFrameworkInference.props" />

<!-- Imports the .user.env file if exists and the build is from VS -->
<Import Project="$(MSBuildProjectFullPath).user.env" Condition="Exists('$(MSBuildProjectFullPath).user.env') And '$(BuildingInsideVisualStudio)' == 'true'" />
<PropertyGroup>
<!-- e.g: C:\Users\user1\app1\app1\obj\ -->
<_MobilePropsDir>$(BaseIntermediateOutputPath)</_MobilePropsDir>
<_MobilePropsDir Condition="!Exists('$(_MobilePropsDir)')">$([System.IO.Path]::GetDirectoryName($(MSBuildProjectFullPath)))\$(BaseIntermediateOutputPath)</_MobilePropsDir>
<!-- e.g: C:\Users\user1\app1\app1\obj\app1.mobile.props -->
<_MobilePropsPath>$(_MobilePropsDir)$(MSBuildProjectName).mobile.props</_MobilePropsPath>
</PropertyGroup>

<!-- Imports the .mobile.props file if exists and the build is from VS -->
<Import Project="$(_MobilePropsPath)" Condition="Exists('$(_MobilePropsPath)') And '$(BuildingInsideVisualStudio)' == 'true'" />

<PropertyGroup>
<!-- Set to true when using the Microsoft.<platform>.Sdk NuGet. This is used by pre-existing/shared targets to tweak behavior depending on build system -->
Expand Down

0 comments on commit 654172d

Please sign in to comment.