Skip to content

fix(msbuild): Stride.AssetCompiler.targets - use Path.Combine for paths - #3340

Open
VaclavElias wants to merge 1 commit into
stride3d:masterfrom
VaclavElias:asset-path
Open

fix(msbuild): Stride.AssetCompiler.targets - use Path.Combine for paths#3340
VaclavElias wants to merge 1 commit into
stride3d:masterfrom
VaclavElias:asset-path

Conversation

@VaclavElias

Copy link
Copy Markdown
Contributor

PR Classification

Bug fix to ensure correct path handling in asset build processes.

PR Summary

Replaced string concatenation with System.IO.Path.Combine for StrideCompileAssetBuildPath and StrideCompileAssetUpToDateCheckFileBase in Stride.AssetCompiler.targets, ensuring intermediate output paths are handled correctly for both normal projects and file-based apps (dotnet run app.cs), whose obj/bin paths are already rooted under the SDK's temp cache.

  • Stride.AssetCompiler.targets: use Path.Combine instead of concatenation for StrideCompileAssetBuildPath and StrideCompileAssetUpToDateCheckFileBase; added explanatory comments

Testing notes

This PR fixes StrideCompileAssetBuildPath and StrideCompileAssetUpToDateCheckFileBase to use
Path.Combine instead of string concatenation, so absolute intermediate paths (e.g. file-based
apps via dotnet run app.cs, whose obj/bin live under the SDK's temp cache) are handled correctly
instead of producing a malformed path.

Verified on Windows. Path.Combine/Path.IsPathRooted rootedness semantics can differ slightly
across platforms, so it would be good to double check normal + file-based app builds on
Linux/macOS, if a maintainer has the setup handy.

- Use Path.Combine for StrideCompileAssetBuildPath and
  StrideCompileAssetUpToDateCheckFileBase
- Fixes malformed paths for file-based apps (dotnet run app.cs) whose
  intermediate output paths are already rooted
@VaclavElias
VaclavElias requested a review from xen2 August 8, 2026 18:07
@VaclavElias

Copy link
Copy Markdown
Contributor Author

References: https://learn.microsoft.com/en-us/dotnet/core/sdk/file-based-apps

Additional context, this change will allow to run Stride (code-only) from any C# file e.g. Program.cs without a project file csproj like the example below.

Without this PR, we have to add also these two lines

#:property BaseIntermediateOutputPath=obj\
#:property OutputPath=bin\
#:package Stride.CommunityToolkit.Bepu@1.0.0-dev
#:package Stride.CommunityToolkit.Skyboxes@1.0.0-dev
#:package Stride.CommunityToolkit.Windows@1.0.0-dev

using Stride.CommunityToolkit.Bepu;
using Stride.CommunityToolkit.Engine;
using Stride.CommunityToolkit.Rendering.ProceduralModels;
using Stride.CommunityToolkit.Skyboxes;
using Stride.Core.Mathematics;
using Stride.Engine;

using var game = new Game();

game.Run(start: Start);

void Start(Scene rootScene)
{
    game.SetupBase3DScene();
    game.AddSkybox();

    var entity = game.Create3DPrimitive(PrimitiveModelType.Capsule);
    entity.Transform.Position = new Vector3(0, 8, 0);
    entity.Scene = rootScene;
}

relative to the project for a normal project, but absolute for a file-based app
(dotnet run app.cs), whose obj/bin live under the SDK's temp cache. Path.Combine returns
the second path unchanged when it is already rooted, so the relative case is unaffected. -->
<StrideCompileAssetBuildPath Condition="'$(StrideCompileAssetBuildPath)' == ''">$([System.IO.Path]::Combine('$(ProjectDir)', '$(BaseIntermediateOutputPath)stride\assetbuild\data'))</StrideCompileAssetBuildPath>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's use this instead:
$([MSBuild]::NormalizePath('$(ProjectDir)', '$(BaseIntermediateOutputPath)', 'stride\assetbuild\data'))
It would match other use (i.e. line 65) and it applies GetFullPath which resolves ..\ from the resulting path and OK with missing trailing slash).

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

Successfully merging this pull request may close these issues.

2 participants