Skip to content
This repository has been archived by the owner on Oct 6, 2023. It is now read-only.

Bug: MSBuild doesn't build all variants #45

Open
2 tasks done
applejag opened this issue Mar 13, 2020 · 2 comments
Open
2 tasks done

Bug: MSBuild doesn't build all variants #45

applejag opened this issue Mar 13, 2020 · 2 comments
Labels
bug Something isn't working

Comments

@applejag
Copy link
Owner

applejag commented Mar 13, 2020

Expected behavior

Building with MSBuild either via dotnet build, MSBuild.exe, or via Visual Studio 2019 results in all the different DLLs used in the package:

/bin/Debug/unity-aot/Newtonsoft.Json.dll
/bin/Debug/unity-standalone/Newtonsoft.Json.dll
/bin/Debug/unity-editor/Newtonsoft.Json.dll
/bin/Debug/unity-portable/Newtonsoft.Json.dll
/bin/Debug/unity-tests/Newtonsoft.Json.dll

Actual behavior

Only some build. Sometimes it even takes multiple builds to get the most builds. But never the full list.

The missing build DLLs are:

/bin/Debug/unity-aot/Newtonsoft.Json.dll
/bin/Debug/unity-standalone/Newtonsoft.Json.dll

Steps to reproduce

  • Clone repo
  • Open solution /Src/Newtonsoft.Json.sln in Visual Studio 2019
  • Start build Ctrl+B

Details

Host machine OS running Unity Editor 👉 Windows

Unity build target 👉 N/A

Newtonsoft.Json-for-Unity package version 👉 12.0.301

I was using Unity version 👉 N/A

Checklist

  • Shutdown Unity, deleted the /Library folder, opened project again in Unity, and problem still remains. (irrelevant)
  • Checked to be using latest version of the package.
@applejag applejag added the bug Something isn't working label Mar 13, 2020
@applejag
Copy link
Owner Author

Suggested solution is to abuse the MSBuild Batching feature.

I successfully did a small sample in the jilleJr/Newstonsoft.Json-for-Unity.Converters repo to target multiple files after a build (https://github.com/jilleJr/Newtonsoft.Json-for-Unity.Converters/blob/880c3d350f1eb3832d553dd0003e245df5b1e520/Src/Newtonsoft.Json.UnityConverters.Tests/Newtonsoft.Json.UnityConverters.Tests.csproj).

I wonder if the same technique can be applied to force multiple builds of the same target framework, as the AOT, Standalone, and Editor builds all use .NET Standard 2.0.

@applejag
Copy link
Owner Author

Nah abusing the Platform targets seems much more appropriate.
There should be no harm in defining a platform for AOT, one for Standalone, one for Editor, etc.
Then rely on the "Batch Build" feature to build them all. Links:

To fix the TargetFramework issue, maybe that could be resolved with having platform-specific target frameworks?
Something like:

<Project Sdk="Microsoft.NET.Sdk">

  <Choose>
    <When Condition="'$(Platform)'=='Tests'">
      <PropertyGroup>
        <TargetFramework>net46</TargetFramework>
      </PropertyGroup>
    </When>
    <When Condition="'$(Platform)'=='Portable'">
      <PropertyGroup>
        <TargetFramework>portable-net45+win8+wpa81+wp8</TargetFramework>
      </PropertyGroup>
    </When>
    <Otherwise>
      <PropertyGroup>
        <TargetFramework>netstandard2.0</TargetFramework>
      </PropertyGroup>
    </Otherwise>
  </Choose>

</Project>

(MSDN on the <Choose> element: https://docs.microsoft.com/en-us/visualstudio/msbuild/choose-element-msbuild?view=vs-2019)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant