c# - c# - Generate Visual Studio project from Unity through CLI - answerstu - answerstu.com answerstu

c# - Generate Visual Studio project from Unity through CLI

What I want to achieve is to generate a Visual Studio project from my Unity project. I know it's possible by just going through the build menu, but my task is to automate builds and for that I have to be able to generate it from the CLI. I came as far as this:

"program files\Unity\Editor\Unity.exe" -quit -batchmode -projectPath "C:\Users\Ruben\Documents\hololens-mapping-movement-poc\HoloLens Mapping and Movement" -executeMethod Build.PerformBuild

Running this command from the CLI on Windows 10 opens Unity to start the project and build (as I assume). My Build script looks like this:

class Build {

    static void PerformBuild()
    {
        string[] scenes = { "Assets/Scene/Main.unity" };
        BuildPipeline.BuildPlayer(scenes, "Scratch/WinRT", BuildTarget.WSAPlayer, BuildOptions.None);
    }
}

What it should do:

  • Start Unity (or as a background task with -batchmode)
  • Generate a Visual Studio project in the App folder as a Windows Universal App

What it doesn't do:

  • Generate a Visual Studio project in the App folder as a Windows Universal App

1 Answer

  1. Mark- Reply

    2019-11-13

    I fixed it with this command:

    "C:\program files\Unity\Editor\Unity.exe" -projectPath "%~dp0\HoloLens Mapping and Movement" -logFile "%~dp0\log.txt" -buildOutput "%~dp0\HoloLens Mapping and Movement\App" -duskBuildTarget WSAPlayer -wsaUWPBuildType D3D -executeMethod HoloToolkit.Unity.BuildSLNUtilities.PerformBuild_CommandLine -batchmode -quit
    

    Because I use the HoloLens Toolkit I use their PerformBuild method. This works obviously. It generates the same Visual Studio files as the default Unity build does.

Leave a Reply

Your email address will not be published. Required fields are marked *

You can use these HTML tags and attributes <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>