Dinomite-Studios / unity-azure-pipelines-tasks

Azure DevOps extension adding tools to build and deploy Unity 3D projects using Azure Pipelines
https://unitydevops.com/
MIT License
121 stars 49 forks source link

Generate logs in another path #246

Closed bdovaz closed 7 months ago

bdovaz commented 10 months ago

@FejZa currently, it is generated in a /Logs folder in the repository root.

It would make sense to generate it in a another path so that it is not so intrusive (i.e. does not generate a file in the working copy of the repository).

There are 2 decisions to make:

The second one is simpler because as the tasks expose output variables with the log paths, if you only depend on that which is logical, there is no breaking change.

The only breaking change can be created if you don't use the ouput variable and "trust" that there is always a /Logs path in the repository root.

bdovaz commented 7 months ago

@FejZa what do you think? I'm willing to create a PR but I'd like to know which one you're leaning towards.

Thanks.

FejZa commented 7 months ago

Hey @bdovaz,

If anything I'd lean towards

Why do you think this is an issue at all? Unity creates a "Logs" folder by default for every project when it is opened the first time. This is where Unity also saves logs for asset import, package updates etc. See this screenshot:

image

This logs folder is usually in gitignore then. Don't really see an issue with the build task dropping its logs in this folder as well.

bdovaz commented 7 months ago

Maybe I have not explained well.

As you mention, Unity creates a Logs folder relative to the project, that is, {ProjectPath}/Logs.

In your case, you do it in the repository root because you use the Build.Repository.LocalPath variable.

Example for Unity CMD:

https://github.com/Dinomite-Studios/unity-azure-pipelines-tasks/blob/62a941331737ff3cec11156236eeb7184a5496c1/Tasks/UnityCMD/UnityCMDV1/unity-cmd.ts#L19

https://github.com/Dinomite-Studios/unity-azure-pipelines-tasks/blob/62a941331737ff3cec11156236eeb7184a5496c1/Tasks/UnityCMD/UnityCMDV1/unity-cmd.ts#L36

Maybe the problem is that you take for granted that in the root of a repository is going to be directly the Unity project but in many cases it is not like that, in our case for example, we follow the Monorepo pattern so in the same repository we have many more things than the Unity project.

In fact, this is even more complicated if you do multi-checkout:

https://learn.microsoft.com/en-us/azure/devops/pipelines/repos/multi-repo-checkout?view=azure-devops#checkout-path

In this case, that Logs folder that it generates is left out of the repository checkout. Example:

C:\agent_work\1\s\repo1 C:\agent_work\1\s\repo2 C:\agent_work\1\s\Logs

Precisely because of these cases the .gitignore file does not act as you think.

FejZa commented 7 months ago

Ok, got it. I was in fact not aware that I simply used 'Build.Repository.LocalPath' here without adding the relative project path as well. This is a bug.

I guess we can go for your second option then. The temporary agent directory should be fine for this.

bdovaz commented 7 months ago

PR created