Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How do I configure the artifacts build output for WebGL #60

Open
MeltdownInteractive opened this issue May 10, 2021 · 1 comment
Open

Comments

@MeltdownInteractive
Copy link

MeltdownInteractive commented May 10, 2021

I am using a self-hosted TeamCity agent, running the Unity plugin.

I have WebGL as the build target, but I cannot for the life of me figure out how to configure the build output to go into a \builds path off the project root.

I can't browse in the TeamCity dialog 'Select files to be published as artifacts', for the artifacts to include, as I don't see the build artifacts listed anywhere in the dialog, just regular folders from my project.

I've done a complete file search on all the TeamCity directories on my PC, looking for the build output, but don't see anything.

I feel like I'm missing some configuration step somewhere, stating where the output of the WebGL build should go to, but I've tried setting the 'artifact paths' setting to */ => build
But I get an error that there were too many artifacts.

I then tried setting the 'artifact paths' setting to just getting my .html file to be exported
build/*.html
But I still don't have any artifacts once my build has been completed.

Thanks

@AaronZurawski
Copy link
Contributor

The build output is not something the Unity runner plugin handles as it doesn't handle building your project, only opening Unity.

You would have your function that you use to build your project control where the build is output and provide that function to the Unity runner's Execute method field.

For most basic configurations, your function will want to call BuildPipeline.BuildPlayer which takes a BuildPlayerOptions struct that has a locationPathName field that you can use to set the output path.

So an example for you might look like this:

namespace BuildUtilities
{
    public static void BuildWebGL()
    {
        BuildPlayerOptions buildPlayerOptions = new BuildPlayerOptions();
        buildPlayerOptions.scenes = new[] { "Assets/Scenes/MyFirstScene.unity", "Assets/Scenes/MySecondScene.unity" };
        buildPlayerOptions.locationPathName = "build";
        buildPlayerOptions.target = BuildTarget.WebGL;
        buildPlayerOptions.options = BuildOptions.None;

        BuildPipeline.BuildPlayer(buildPlayerOptions);
    }
}

This is only a sample, I would recommend reading Unity's EditorBuildSettings.scenes and transform that into the scene paths that BuildPlayer takes so that your builds remain in sync with the editor.

You would then add BuildUtilities.BuildWebGL to the Execute method field in the runner configuration, and have your artifact paths contain something like build/**/* => MyWebGLBuild.zip if you wanted TeamCity to zip the folder output for you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants