I'm building an app for windows only, that needs to consume a docx file using .net MAUI.
I use the suggested class IFilePicker, implemented it, and worked fine while debugging (both in debug and release mode).
So, after finished a preview version, I want to deploy unpacked, "like a portable version", using:
MSBuild.exe D:\Workspace\dotNet\WordReplacer\WordReplacer.App\ /restore /t:Publish /p:TargetFramework=net6.0-windows10.0.19041 /p:configuration=release /p:WindowsAppSDKSelfContained=true /p:Platform=x64 /p:PublishSingleFile=true /p:WindowsPackageType=None /p:RuntimeIdentifier=win10-x64
Everthing works fine just as debug, except for the FilePicker that doesn't work and gives me the error:
Value does not fall within the expected range
This error doesn't happen if I install a published package with a certificate. So maybe I'm missing something in the msbuilder workaround to generate an unpacked app.
I'm using the communitytoolkit.MVVM and the method that I use to pick the file stays in my viewmodel:
private string _inputFilePath;
[ObservableProperty]
private string _inputFileNameText = "Select a input file";
[RelayCommand]
public async Task PickInputDocAsync()
{
try
{
var customFileType = new FilePickerFileType(
new Dictionary<DevicePlatform, IEnumerable<string>>
{
{ DevicePlatform.WinUI, new[] { ".doc", ".docx" } },
});
PickOptions options = new()
{
PickerTitle = "Please select a document",
FileTypes = customFileType,
};
var result = await FilePicker.Default.PickAsync(options).ConfigureAwait(false);
if (result != null)
{
_inputFilePath = result.FullPath;
InputFileNameText = result.FileName;
}
}
catch (Exception ex)
{
ErrorMessage = $"{ex.InnerException?.Message} Error: {ex.Message}, InputFilePath: {_inputFilePath}, InputFileName: {InputFileNameText}";
}
Any clue how to fix it?