maui icon indicating copy to clipboard operation
maui copied to clipboard

Appsettings build error

Open dom93dd opened this issue 2 years ago • 1 comments

Description

Whenever I am building a dotnet maui app a recurring error appears:

appsettings.json : error : The path '../../../../../../../../../Users/user/Documents/repos/repo/modules/mobile-app/appsettings.json' would result in a file outside of the app bundle and cannot be used.

The appsettings are loaded in the MauiProgram.cs:

using var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("mobile_app.appsettings.json"); var config = new ConfigurationBuilder().AddJsonStream(stream).Build(); builder.Configuration.AddConfiguration(config);

This is how the appsettings.json is referenced in the csproj file:

    <ItemGroup>
      <EmbeddedResource Include="appsettings.json">
        <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
      </EmbeddedResource>
    </ItemGroup>

Steps to Reproduce

Clean Project -> Rebuild Project -> Error appears.

Link to public reproduction project repository

none

Version with bug

7.0 Release Candidate 2

Last version that worked well

Unknown/Other

Affected platforms

macOS

Affected platform versions

macOS 12.5.1 (21G83)

Did you find any workaround?

When I delete this file and adding it again in visual studio, for sometime this error is disappearing.

Relevant log output

Target _CollectBundleResources:
        appsettings.json : error : The path '../../../../../../../../../Users/user/Documents/repos/repo/modules/mobile-app/appsettings.json' would result in a file outside of the app bundle and cannot be used.
        appsettings.json : error :         
    Done building target "_CollectBundleResources" in project "mobile-app.csproj" -- FAILED.

    Done building project "mobile-app.csproj" -- FAILED.

dom93dd avatar Oct 25 '22 18:10 dom93dd

We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.

ghost avatar Oct 26 '22 18:10 ghost

Hi @raxtorDD. We have added the "s/try-latest-version" label to this issue, which indicates that we'd like you to try and reproduce this issue on the latest available public version. This can happen because we think that this issue was fixed in a version that has just been released, or the information provided by you indicates that you might be working with an older version.

You can install the latest version by installing the latest Visual Studio (Preview) with the .NET MAUI workload installed. If the issue still persists, please let us know with any additional details and ideally a reproduction project provided through a GitHub repository.

This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

ghost avatar Jan 20 '23 19:01 ghost