Mobile.BuildTools icon indicating copy to clipboard operation
Mobile.BuildTools copied to clipboard

[.NET 8.0] Build crash System.Security.Permissions missing

Open Px7-941 opened this issue 1 year ago • 9 comments

Description

Build crashes with "Could not load file or assembly System.Security.Permissions" .

https://learn.microsoft.com/en-us/dotnet/core/compatibility/extensions/8.0/configurationmanager-package https://learn.microsoft.com/en-us/dotnet/core/compatibility/8.0#extensions

Reproduction Steps

Steps to reproduce the behavior:

  1. Install https://github.com/dotnet/core/blob/main/release-notes/8.0/preview/8.0.0-rc.2.md
  2. Create .NET 8.0 console project
  3. Setup appsettings feature from Mobile.BuildTools
  4. Build

Expected Behavior

Generate app settings class (https://mobilebuildtools.com/config/appsettings/).

Actual Behavior

/Users/runner/.nuget/packages/mobile.buildtools/2.0.245/build/Mobile.BuildTools.targets(37,5): 
error MSB4018: The "LocateBuildToolsConfigTask" task failed unexpectedly. 
[/Users/runner/work/mobile-app/mobile-app/src/Mobile.Business/Mobile.Business.csproj::TargetFramework=net8.0]

/Users/runner/.nuget/packages/mobile.buildtools/2.0.245/build/Mobile.BuildTools.targets(37,5): 
error MSB4018: System.IO.FileNotFoundException: 
Could not load file or assembly 'System.Security.Permissions, Version=0.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. 
The system cannot find the file specified. 
[/Users/runner/work/mobile-app/mobile-app/src/Mobile.Business/Mobile.Business.csproj::TargetFramework=net8.0]

Environment

  • OS: [OSX]
  • IDE: [VSMac|CLI|Rider]
  • BuildTools Version: [2.0.245]
  • IDE Version: [-]
  • Build Target Framework: [MAUI-8.0|NET-8.0]

Reproduction App

ConsoleApp1.zip

Px7-941 avatar Oct 17 '23 09:10 Px7-941

Bump, with the release and installation of .net 8, a .net 7 project now fails with this error. Is there a release/pre-release coming for this?

Thanks.

Edit : To anyone else having this issue, a workaround was to add the following global.json file to the root of my project.

{
  "sdk": {
    "version": "7.0.404",
    "rollForward": "latestFeature"
  }
}

robfrancis avatar Nov 18 '23 07:11 robfrancis

I have the same issue building a MAUI project, on the released version of net8 sdk (8.0.100) when building an android app on azure dev ops. Locally, it builds fine.

I tried adding a global.json at the root of my project file with these contents, it doesn't help.

    {
    "sdk": {
      "version": "8.0.100",
      "rollForward": "latestFeature"
    }
  }

Here's the stack trace from the azure dev ops pipeline

[D:\a\1\s\SourceCode\ClientApps\VisualService.Tech\VisualService.Tech.csproj::TargetFramework=net8.0-android]
D:\a\1\.nuget\packages\mobile.buildtools\2.0.245\build\Mobile.BuildTools.targets(37,5): error MSB4018: The "LocateBuildToolsConfigTask" task failed unexpectedly. [D:\a\1\s\SourceCode\ClientApps\Common\VisualService.Settings\VisualService.Settings.csproj]
D:\a\1\.nuget\packages\mobile.buildtools\2.0.245\build\Mobile.BuildTools.targets(37,5): error MSB4018: System.IO.FileNotFoundException: Could not load file or assembly 'System.Security.Permissions, Version=0.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. The system cannot find the file specified. [D:\a\1\s\SourceCode\ClientApps\Common\VisualService.Settings\VisualService.Settings.csproj]
D:\a\1\.nuget\packages\mobile.buildtools\2.0.245\build\Mobile.BuildTools.targets(37,5): error MSB4018: File name: 'System.Security.Permissions, Version=0.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' [D:\a\1\s\SourceCode\ClientApps\Common\VisualService.Settings\VisualService.Settings.csproj]
D:\a\1\.nuget\packages\mobile.buildtools\2.0.245\build\Mobile.BuildTools.targets(37,5): error MSB4018:    at Newtonsoft.Json.Serialization.JsonTypeReflector.get_ReflectionDelegateFactory() [D:\a\1\s\SourceCode\ClientApps\Common\VisualService.Settings\VisualService.Settings.csproj]
D:\a\1\.nuget\packages\mobile.buildtools\2.0.245\build\Mobile.BuildTools.targets(37,5): error MSB4018:    at Newtonsoft.Json.Serialization.DefaultContractResolver.GetDefaultCreator(Type createdType) [D:\a\1\s\SourceCode\ClientApps\Common\VisualService.Settings\VisualService.Settings.csproj]
D:\a\1\.nuget\packages\mobile.buildtools\2.0.245\build\Mobile.BuildTools.targets(37,5): error MSB4018:    at Newtonsoft.Json.Serialization.DefaultContractResolver.InitializeContract(JsonContract contract) [D:\a\1\s\SourceCode\ClientApps\Common\VisualService.Settings\VisualService.Settings.csproj]
D:\a\1\.nuget\packages\mobile.buildtools\2.0.245\build\Mobile.BuildTools.targets(37,5): error MSB4018:    at Newtonsoft.Json.Serialization.DefaultContractResolver.CreateObjectContract(Type objectType) [D:\a\1\s\SourceCode\ClientApps\Common\VisualService.Settings\VisualService.Settings.csproj]
D:\a\1\.nuget\packages\mobile.buildtools\2.0.245\build\Mobile.BuildTools.targets(37,5): error MSB4018:    at Newtonsoft.Json.Serialization.DefaultContractResolver.CreateContract(Type objectType) [D:\a\1\s\SourceCode\ClientApps\Common\VisualService.Settings\VisualService.Settings.csproj]
D:\a\1\.nuget\packages\mobile.buildtools\2.0.245\build\Mobile.BuildTools.targets(37,5): error MSB4018:    at System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory) [D:\a\1\s\SourceCode\ClientApps\Common\VisualService.Settings\VisualService.Settings.csproj]
D:\a\1\.nuget\packages\mobile.buildtools\2.0.245\build\Mobile.BuildTools.targets(37,5): error MSB4018:    at Newtonsoft.Json.Utilities.ThreadSafeStore`2.Get(TKey key) [D:\a\1\s\SourceCode\ClientApps\Common\VisualService.Settings\VisualService.Settings.csproj]
D:\a\1\.nuget\packages\mobile.buildtools\2.0.245\build\Mobile.BuildTools.targets(37,5): error MSB4018:    at Newtonsoft.Json.Serialization.DefaultContractResolver.ResolveContract(Type type) [D:\a\1\s\SourceCode\ClientApps\Common\VisualService.Settings\VisualService.Settings.csproj]
D:\a\1\.nuget\packages\mobile.buildtools\2.0.245\build\Mobile.BuildTools.targets(37,5): error MSB4018:    at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.GetContract(Type type) [D:\a\1\s\SourceCode\ClientApps\Common\VisualService.Settings\VisualService.Settings.csproj]
D:\a\1\.nuget\packages\mobile.buildtools\2.0.245\build\Mobile.BuildTools.targets(37,5): error MSB4018:    at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.GetContractSafe(Type type) [D:\a\1\s\SourceCode\ClientApps\Common\VisualService.Settings\VisualService.Settings.csproj]
D:\a\1\.nuget\packages\mobile.buildtools\2.0.245\build\Mobile.BuildTools.targets(37,5): error MSB4018:    at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent) [D:\a\1\s\SourceCode\ClientApps\Common\VisualService.Settings\VisualService.Settings.csproj]
D:\a\1\.nuget\packages\mobile.buildtools\2.0.245\build\Mobile.BuildTools.targets(37,5): error MSB4018:    at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType) [D:\a\1\s\SourceCode\ClientApps\Common\VisualService.Settings\VisualService.Settings.csproj]
D:\a\1\.nuget\packages\mobile.buildtools\2.0.245\build\Mobile.BuildTools.targets(37,5): error MSB4018:    at Newtonsoft.Json.JsonSerializer.Deserialize(JsonReader reader, Type objectType) [D:\a\1\s\SourceCode\ClientApps\Common\VisualService.Settings\VisualService.Settings.csproj]
D:\a\1\.nuget\packages\mobile.buildtools\2.0.245\build\Mobile.BuildTools.targets(37,5): error MSB4018:    at Newtonsoft.Json.JsonConvert.DeserializeObject(String value, Type type, JsonSerializerSettings settings) [D:\a\1\s\SourceCode\ClientApps\Common\VisualService.Settings\VisualService.Settings.csproj]
D:\a\1\.nuget\packages\mobile.buildtools\2.0.245\build\Mobile.BuildTools.targets(37,5): error MSB4018:    at Newtonsoft.Json.JsonConvert.DeserializeObject[T](String value, JsonSerializerSettings settings) [D:\a\1\s\SourceCode\ClientApps\Common\VisualService.Settings\VisualService.Settings.csproj]
D:\a\1\.nuget\packages\mobile.buildtools\2.0.245\build\Mobile.BuildTools.targets(37,5): error MSB4018:    at Mobile.BuildTools.Utils.ConfigHelper.GetConfig(String path, Boolean skipActivation) in D:\a\1\s\src\Mobile.BuildTools.Reference\Utils\ConfigHelper.shared.cs:line 73 [D:\a\1\s\SourceCode\ClientApps\Common\VisualService.Settings\VisualService.Settings.csproj]
D:\a\1\.nuget\packages\mobile.buildtools\2.0.245\build\Mobile.BuildTools.targets(37,5): error MSB4018:    at Mobile.BuildTools.Tasks.LocateBuildToolsConfigTask.MigrateSecretsToSettings() in D:\a\1\s\src\Mobile.BuildTools\Tasks\LocateBuildToolsConfigTask.cs:line 121 [D:\a\1\s\SourceCode\ClientApps\Common\VisualService.Settings\VisualService.Settings.csproj]
D:\a\1\.nuget\packages\mobile.buildtools\2.0.245\build\Mobile.BuildTools.targets(37,5): error MSB4018:    at Mobile.BuildTools.Tasks.LocateBuildToolsConfigTask.Execute() in D:\a\1\s\src\Mobile.BuildTools\Tasks\LocateBuildToolsConfigTask.cs:line 69 [D:\a\1\s\SourceCode\ClientApps\Common\VisualService.Settings\VisualService.Settings.csproj]
D:\a\1\.nuget\packages\mobile.buildtools\2.0.245\build\Mobile.BuildTools.targets(37,5): error MSB4018:    at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute() [D:\a\1\s\SourceCode\ClientApps\Common\VisualService.Settings\VisualService.Settings.csproj]
D:\a\1\.nuget\packages\mobile.buildtools\2.0.245\build\Mobile.BuildTools.targets(37,5): error MSB4018:    at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask(ITaskExecutionHost taskExecutionHost, TaskLoggingContext taskLoggingContext, TaskHost taskHost, ItemBucket bucket, TaskExecutionMode howToExecuteTask) [D:\a\1\s\SourceCode\ClientApps\Common\VisualService.Settings\VisualService.Settings.csproj]
D:\a\1\s\SourceCode\Common\VisualService.Utilities\Models\OfflineBase.cs(30,87): warning CS8632: The annotation for nullable reference types should only be used in code within a '#nullable' annotations context. [D:\a\1\s\SourceCode\Common\VisualService.Utilities\VisualService.Utilities.csproj]


AdamDiament avatar Dec 11 '23 12:12 AdamDiament

Internally we use our own customized Nuget build with the System.Text.Json migration.

https://github.com/dansiegel/Mobile.BuildTools/pull/335

Px7-941 avatar Dec 11 '23 14:12 Px7-941

Internally we use our own customized Nuget build with the System.Text.Json migration.

#335

@Px7-941 that sounds excellent. Is this customised nuget package something you could share at all?

AdamDiament avatar Dec 11 '23 14:12 AdamDiament

Internally we use our own customized Nuget build with the System.Text.Json migration.

#335

You know I do take PRs

dansiegel avatar Dec 11 '23 20:12 dansiegel

@dansiegel you can check the PR. Your main/master did not work as our base. We used your last release branch.

Px7-941 avatar Dec 12 '23 13:12 Px7-941

@Px7-941 thanks - would you be willing to share your local nuget package with me in the meantime please?

AdamDiament avatar Dec 12 '23 13:12 AdamDiament

@AdamDiament here is our own Nuget, we only tested the appsettings generation feature. GitHub blocks the ".nupkg" extension, remove the .zip extension. mobile.buildtools.2.0.39-g3081c6739d.nupkg.zip

Px7-941 avatar Dec 14 '23 11:12 Px7-941

@AdamDiament here is our own Nuget, we only tested the appsettings generation feature. GitHub blocks the ".nupkg" extension, remove the .zip extension. mobile.buildtools.2.0.39-g3081c6739d.nupkg.zip

Thanks very much @Px7-941, it works like a dream! We only use the AppSettings feature in any case.

@dansiegel thanks again for an amazing project, looking forward to this making it into the main repo

AdamDiament avatar Dec 14 '23 13:12 AdamDiament