[GH-ISSUE #146] Can't find Main.qml unless <RunWorkingDirectory> property set in .csproj #88

Closed
opened 2026-05-05 11:04:06 -06:00 by gitea-mirror · 5 comments
Owner

Originally created by @zzstuzor on GitHub (Jun 23, 2019).
Original GitHub issue: https://github.com/qmlnet/qmlnet/issues/146

Have got the example project working - very cool.

Tried to create my own, couldn't get it working. Even copying all the code directly out of the example project. Tried everything, eventually narrowed it down to a property that exists in the Features.csproj in the example, and it doesn't work unless this is set.

<PropertyGroup>
    <RunWorkingDirectory>$(MSBuildProjectDirectory)</RunWorkingDirectory>
</PropertyGroup>

Sharing in case others have the same problem.

Was this something you added to the .csproj manually? Or is there some step to add this in project settings or during some process?

Originally created by @zzstuzor on GitHub (Jun 23, 2019). Original GitHub issue: https://github.com/qmlnet/qmlnet/issues/146 Have got the example project working - very cool. Tried to create my own, couldn't get it working. Even copying all the code directly out of the example project. Tried everything, eventually narrowed it down to a property that exists in the Features.csproj in the example, and it doesn't work unless this is set. ``` <PropertyGroup> <RunWorkingDirectory>$(MSBuildProjectDirectory)</RunWorkingDirectory> </PropertyGroup> ``` Sharing in case others have the same problem. Was this something you added to the .csproj manually? Or is there some step to add this in project settings or during some process?
Author
Owner

@vadi2 commented on GitHub (Jun 23, 2019):

I don't have it set (https://github.com/health-validator/Hammer/blob/master/Hammer.csproj) and things seem to be working out OK.

<!-- gh-comment-id:504765526 --> @vadi2 commented on GitHub (Jun 23, 2019): I don't have it set (https://github.com/health-validator/Hammer/blob/master/Hammer.csproj) and things seem to be working out OK.
Author
Owner

@pauldotknopf commented on GitHub (Jun 27, 2019):

@zzstuzor, you are correct. The samples, as they are, require Main.qml to be in the current working directory.

This can be changed by changing where you load the QML (qmlEngine.Load("Main.qml");). You could put the Main.qml anywhere, just make sure you reference it correctly in Load(string qmlPath).

Side note, there is plan to support loading QML files from embedded .NET resources (#15).

<!-- gh-comment-id:506343319 --> @pauldotknopf commented on GitHub (Jun 27, 2019): @zzstuzor, you are correct. The samples, as they are, require ```Main.qml``` to be in the current working directory. This can be changed by changing where you load the QML (```qmlEngine.Load("Main.qml");```). You could put the ```Main.qml``` anywhere, just make sure you reference it correctly in ```Load(string qmlPath)```. Side note, there is plan to support loading QML files from embedded .NET resources (#15).
Author
Owner

@vadi2 commented on GitHub (Jun 27, 2019):

And if you'd like to use the new PublishSingleFile option which unzips your dll are runtime to a location unknown to you, you can use engine.Load(Path.Combine(Path.GetDirectoryName(Assembly.GetEntryAssembly()?.Location), "Main.qml")); to load the file.

<!-- gh-comment-id:506347568 --> @vadi2 commented on GitHub (Jun 27, 2019): And if you'd like to use the new `PublishSingleFile` option which unzips your dll are runtime to a location unknown to you, you can use `engine.Load(Path.Combine(Path.GetDirectoryName(Assembly.GetEntryAssembly()?.Location), "Main.qml"));` to load the file.
Author
Owner

@zzstuzor commented on GitHub (Jun 30, 2019):

@pauldotknopf ok right I see, that makes sense.

Side note, there is plan to support loading QML files from embedded .NET resources (#15).

This sounds awesome. For deploying an application with dotnet it seems most appropriate to have those QML files embedded somehow.

And if you'd like to use the new PublishSingleFile option which unzips your dll are runtime to a location unknown to you, you can use engine.Load(Path.Combine(Path.GetDirectoryName(Assembly.GetEntryAssembly()?.Location), "Main.qml")); to load the file.

This also sounds like an alternative. I'll try to test this out in the next few weeks/months. I'm very interested in developing a cross-platform app, but I'm doing it in my spare time. Each night I try to learn more about QML.

I still can't get the demo application running on my linux machine though :-\

<!-- gh-comment-id:507034248 --> @zzstuzor commented on GitHub (Jun 30, 2019): @pauldotknopf ok right I see, that makes sense. > Side note, there is plan to support loading QML files from embedded .NET resources (#15). This sounds awesome. For deploying an application with dotnet it seems most appropriate to have those QML files embedded somehow. > And if you'd like to use the new PublishSingleFile option which unzips your dll are runtime to a location unknown to you, you can use engine.Load(Path.Combine(Path.GetDirectoryName(Assembly.GetEntryAssembly()?.Location), "Main.qml")); to load the file. This also sounds like an alternative. I'll try to test this out in the next few weeks/months. I'm very interested in developing a cross-platform app, but I'm doing it in my spare time. Each night I try to learn more about QML. I still can't get the demo application running on my linux machine though :-\
Author
Owner

@vadi2 commented on GitHub (Jun 30, 2019):

Check my Hammer app - I'm making it on Ubuntu, and it runs on macOS and Windows as well.

<!-- gh-comment-id:507034548 --> @vadi2 commented on GitHub (Jun 30, 2019): Check my Hammer app - I'm making it on Ubuntu, and it runs on macOS and Windows as well.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: github-starred/qmlnet#88
No description provided.