dansiegel / Mobile.BuildTools

The Mobile.BuildTools makes it easier to develop code bases in a clean, consistent, secure, and configurable way. Determine at Build which environment your app needs to run on, and what Client Secrets it should have. Plus many more amazing features!
http://mobilebuildtools.com
MIT License
228 stars 29 forks source link

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

Open Px7-941 opened 8 months ago

Px7-941 commented 8 months ago

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

Reproduction App

ConsoleApp1.zip

robfrancis commented 7 months ago

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"
  }
}
AdamDiament commented 7 months ago

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]
Px7-941 commented 7 months ago

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

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

AdamDiament commented 7 months ago

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?

dansiegel commented 7 months ago

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

335

You know I do take PRs

Px7-941 commented 6 months ago

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

AdamDiament commented 6 months ago

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

Px7-941 commented 6 months ago

@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

AdamDiament commented 6 months ago

@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