Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

On ppc64le, VMR at 8 Preview 6 doesn't build using itself #3571

Closed
omajid opened this issue Jul 27, 2023 · 22 comments · Fixed by dotnet/msbuild#9158
Closed

On ppc64le, VMR at 8 Preview 6 doesn't build using itself #3571

omajid opened this issue Jul 27, 2023 · 22 comments · Fixed by dotnet/msbuild#9158
Assignees
Labels
area-upstream-fix Needs a change in a contributing repo

Comments

@omajid
Copy link
Member

omajid commented Jul 27, 2023

Describe the Bug

We are trying to confirm that source-build can build using itself.

This works on x64. We can build .NET 8 Preview 6 offline (after using the bits downloaded by prep.sh), then use what we just-built to build .NET 8 Preview 6 itself completely offline.

This doesn't work on ppc64le. We can build .NET 8 Preview 6 using a cross-compiled ppc64le SDK and the bits downloaded by prep.sh. We can do this offline too. But then using that just-built SDK to build .NET 8 Preview 6 again fails on ppc64le. The error happens when building runtime.

Steps to Reproduce

Other Information

    'ARCADE_SHARED_FX_SDK' for 'Microsoft.DotNet.SharedFramework.Sdk/8.0.0-beta.23371.1' at 'dotnet/artifacts/source-built-sdks/Microsoft.DotNet.SharedFramework.Sdk/'
    'ARCADE' for 'Microsoft.DotNet.Arcade.Sdk/8.0.0-beta.23371.1' at 'dotnet/artifacts/source-built-sdks/Microsoft.DotNet.Arcade.Sdk/'
    'ARCADE_PACKAGING' for 'Microsoft.DotNet.Build.Tasks.Packaging/8.0.0-beta.23371.1' at dotnet/artifacts/source-built-sdks/Microsoft.DotNet.Build.Tasks.Packaging/'
    [SourceBuiltSdkResolver] Overriding Microsoft.DotNet.SharedFramework.Sdk with 'ARCADE_SHARED_FX_SDK'
  new_tarball/sdk/8.0.100-preview.6.23330.1/NuGet.RestoreEx.targets(19,5): error : Failure has occurred while loading a type. [dotnet/src/runtime/artifacts/source-build/self/src/Build.proj]
  new_tarball/sdk/8.0.100-preview.6.23330.1/NuGet.RestoreEx.targets(19,5): error :    at Microsoft.Build.Shared.ExceptionHandling.NotExpectedIoOrXmlException(Exception e) [dotnet/src/runtime/artifacts/source-build/self/src/Build.proj]
  new_tarball/sdk/8.0.100-preview.6.23330.1/NuGet.RestoreEx.targets(19,5): error :    at Microsoft.Build.Construction.ProjectRootElement.LoadDocument(String fullPath, Boolean preserveFormatting, Boolean loadAsReadOnly) [dotnet/src/runtime/artifacts/source-build/self/src/Build.proj]
  new_tarball/sdk/8.0.100-preview.6.23330.1/NuGet.RestoreEx.targets(19,5): error :    at Microsoft.Build.Construction.ProjectRootElement..ctor(String path, ProjectRootElementCacheBase projectRootElementCache, Boolean preserveFormatting) [dotnet/src/runtime/artifacts/source-build/self/src/Build.proj]
  new_tarball/sdk/8.0.100-preview.6.23330.1/NuGet.RestoreEx.targets(19,5): error :    at Microsoft.Build.Construction.ProjectRootElement.CreateProjectFromPath(String projectFile, ProjectRootElementCacheBase projectRootElementCache, Boolean preserveFormatting) [dotnet/src/runtime/artifacts/source-build/self/src/Build.proj]
  new_tarball/sdk/8.0.100-preview.6.23330.1/NuGet.RestoreEx.targets(19,5): error :    at Microsoft.Build.Construction.ProjectRootElement.<>c.<OpenProjectOrSolution>b__209_0(String path, ProjectRootElementCacheBase cache) [dotnet/src/runtime/artifacts/source-build/self/src/Build.proj]
  new_tarball/sdk/8.0.100-preview.6.23330.1/NuGet.RestoreEx.targets(19,5): error :    at Microsoft.Build.Evaluation.ProjectRootElementCache.GetOrLoad(String projectFile, OpenProjectRootElement loadProjectRootElement, Boolean isExplicitlyLoaded, Nullable`1 preserveFormatting) [dotnet/src/runtime/artifacts/source-build/self/src/Build.proj]
  new_tarball/sdk/8.0.100-preview.6.23330.1/NuGet.RestoreEx.targets(19,5): error :    at Microsoft.Build.Evaluation.ProjectRootElementCache.Get(String projectFile, OpenProjectRootElement loadProjectRootElement, Boolean isExplicitlyLoaded, Nullable`1 preserveFormatting) [dotnet/src/runtime/artifacts/source-build/self/src/Build.proj]
  new_tarball/sdk/8.0.100-preview.6.23330.1/NuGet.RestoreEx.targets(19,5): error :    at Microsoft.Build.Construction.ProjectRootElement.OpenProjectOrSolution(String fullPath, IDictionary`2 globalProperties, String toolsVersion, ProjectRootElementCacheBase projectRootElementCache, Boolean isExplicitlyLoaded) [dotnet/src/runtime/artifacts/source-build/self/src/Build.proj]
  new_tarball/sdk/8.0.100-preview.6.23330.1/NuGet.RestoreEx.targets(19,5): error :    at Microsoft.Build.Evaluation.Evaluator`4[[Microsoft.Build.Execution.ProjectPropertyInstance, Microsoft.Build, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a],[Microsoft.Build.Execution.ProjectItemInstance, Microsoft.Build, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a],[Microsoft.Build.Execution.ProjectMetadataInstance, Microsoft.Build, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a],[Microsoft.Build.Execution.ProjectItemDefinitionInstance, Microsoft.Build, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]].ExpandAndLoadImportsFromUnescapedImportExpression(String directoryOfImportingFile, ProjectImportElement importElement, String unescapedExpression, Boolean throwOnFileNotExistsError, List`1& imports) [dotnet/src/runtime/artifacts/source-build/self/src/Build.proj]
  new_tarball/sdk/8.0.100-preview.6.23330.1/NuGet.RestoreEx.targets(19,5): error :    at Microsoft.Build.Evaluation.Evaluator`4[[Microsoft.Build.Execution.ProjectPropertyInstance, Microsoft.Build, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a],[Microsoft.Build.Execution.ProjectItemInstance, Microsoft.Build, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a],[Microsoft.Build.Execution.ProjectMetadataInstance, Microsoft.Build, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a],[Microsoft.Build.Execution.ProjectItemDefinitionInstance, Microsoft.Build, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]].ExpandAndLoadImportsFromUnescapedImportExpressionConditioned(String directoryOfImportingFile, ProjectImportElement importElement, List`1& projects, SdkResult& sdkResult) [dotnet/src/runtime/artifacts/source-build/self/src/Build.proj]
  new_tarball/sdk/8.0.100-preview.6.23330.1/NuGet.RestoreEx.targets(19,5): error :    at Microsoft.Build.Evaluation.Evaluator`4[[Microsoft.Build.Execution.ProjectPropertyInstance, Microsoft.Build, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a],[Microsoft.Build.Execution.ProjectItemInstance, Microsoft.Build, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a],[Microsoft.Build.Execution.ProjectMetadataInstance, Microsoft.Build, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a],[Microsoft.Build.Execution.ProjectItemDefinitionInstance, Microsoft.Build, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]].ExpandAndLoadImports(String directoryOfImportingFile, ProjectImportElement importElement, SdkResult& sdkResult) [dotnet/src/runtime/artifacts/source-build/self/src/Build.proj]
...
...
  new_tarball/sdk/8.0.100-preview.6.23330.1/NuGet.RestoreEx.targets(19,5): error :    at Microsoft.Build.Execution.ProjectInstance.FromFile(String file, ProjectOptions options) [dotnet/src/runtime/artifacts/source-build/self/src/Build.proj]
  new_tarball/sdk/8.0.100-preview.6.23330.1/NuGet.RestoreEx.targets(19,5): error :    at NuGet.Build.Tasks.Console.MSBuildStaticGraphRestore.<>c__DisplayClass38_0.<LoadProjects>b__0(String path, Dictionary`2 properties, ProjectCollection collection) [dotnet/src/runtime/artifacts/source-build/self/src/Build.proj]
  new_tarball/sdk/8.0.100-preview.6.23330.1/NuGet.RestoreEx.targets(19,5): error :    at Microsoft.Build.Graph.GraphBuilder.ParseProject(ConfigurationMetadata configurationMetadata) [dotnet/src/runtime/artifacts/source-build/self/src/Build.proj]
  new_tarball/sdk/8.0.100-preview.6.23330.1/NuGet.RestoreEx.targets(19,5): error :    at Microsoft.Build.Graph.GraphBuilder.<>c__DisplayClass35_0.<SubmitProjectForParsing>b__0() [dotnet/src/runtime/artifacts/source-build/self/src/Build.proj]
  new_tarball/sdk/8.0.100-preview.6.23330.1/NuGet.RestoreEx.targets(19,5): error :    at System.Lazy`1[[Microsoft.Build.Graph.ParsedProject, Microsoft.Build, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]].ViaFactory(LazyThreadSafetyMode mode) [dotnet/src/runtime/artifacts/source-build/self/src/Build.proj]
  new_tarball/sdk/8.0.100-preview.6.23330.1/NuGet.RestoreEx.targets(19,5): error :    at System.Lazy`1[[Microsoft.Build.Graph.ParsedProject, Microsoft.Build, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]].ExecutionAndPublication(LazyHelper executionAndPublication, Boolean useDefaultConstructor) [dotnet/src/runtime/artifacts/source-build/self/src/Build.proj]
  new_tarball/sdk/8.0.100-preview.6.23330.1/NuGet.RestoreEx.targets(19,5): error :    at System.Lazy`1[[Microsoft.Build.Graph.ParsedProject, Microsoft.Build, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]].CreateValue() [dotnet/src/runtime/artifacts/source-build/self/src/Build.proj]
  new_tarball/sdk/8.0.100-preview.6.23330.1/NuGet.RestoreEx.targets(19,5): error :    at System.Lazy`1[[Microsoft.Build.Graph.ParsedProject, Microsoft.Build, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]].get_Value() [dotnet/src/runtime/artifacts/source-build/self/src/Build.proj]
  new_tarball/sdk/8.0.100-preview.6.23330.1/NuGet.RestoreEx.targets(19,5): error :    at Microsoft.Build.Graph.ParallelWorkSet`2[[Microsoft.Build.BackEnd.ConfigurationMetadata, Microsoft.Build, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a],[Microsoft.Build.Graph.ParsedProject, Microsoft.Build, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]].ExecuteWorkItem() [dotnet/src/runtime/artifacts/source-build/self/src/Build.proj]
    Nothing to do. None of the projects specified contain packages to restore.
@dotnet-issue-labeler
Copy link

I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.

@omajid
Copy link
Member Author

omajid commented Jul 27, 2023

cc @janani66 @Swapnali911

@MichaelSimons MichaelSimons moved this from Backlog to 8.0 GA in .NET Source Build Aug 3, 2023
@MichaelSimons MichaelSimons added area-upstream-fix Needs a change in a contributing repo and removed untriaged labels Aug 3, 2023
@Swapnali911
Copy link

Swapnali911 commented Aug 7, 2023

Able to reproduce on x86 as well with mono

/root/jenkins-scripts/ci/check_sb/new_tarball/sdk/8.0.100-preview.6.23330.1/NuGet.RestoreEx.targets(19,5): error : Failure has occurred while loading a type. [/root/jenkins-scripts/ci/check_sb/dotnet/src/runtime/artifacts/source-build/self/src/Build.proj]
    /root/jenkins-scripts/ci/check_sb/new_tarball/sdk/8.0.100-preview.6.23330.1/NuGet.RestoreEx.targets(19,5): error :    at Microsoft.Build.Shared.ExceptionHandling.NotExpectedIoOrXmlException(Exception e) [/root/jenkins-scripts/ci/check_sb/dotnet/src/runtime/artifacts/source-build/self/src/Build.proj]
    /root/jenkins-scripts/ci/check_sb/new_tarball/sdk/8.0.100-preview.6.23330.1/NuGet.RestoreEx.targets(19,5): error :    at Microsoft.Build.Construction.ProjectRootElement.LoadDocument(String fullPath, Boolean preserveFormatting, Boolean loadAsReadOnly) [/root/jenkins-scripts/ci/check_sb/dotnet/src/runtime/artifacts/source-build/self/src/Build.proj]
...
...
 ##vso[task.logissue type=error;sourcepath=/root/jenkins-scripts/ci/check_sb/dotnet/artifacts/source-built-sdks/Microsoft.DotNet.Arcade.Sdk/tools/SourceBuild/SourceBuildArcadeBuild.targets;linenumber=195;columnnumber=5;code=MSB3073;]The command "./build.sh  --arch x64 --configuration Release --allconfigurations --verbosity minimal --nodereuse false --warnAsError false --outputrid rhel.8-x64 /p:PackageOS=rhel.8 /p:ToolsOS=rhel.8 /p:AdditionalRuntimeIdentifierParent=linux /p:ArcadeBuildFromSource=true /p:OfficialBuildId=20230629.7 /p:ContinuousIntegrationBuild=true --usemonoruntime /p:ArcadeInnerBuildFromSource=true /p:DotNetBuildFromSource=true /p:RepoRoot=/root/jenkins-scripts/ci/check_sb/dotnet/src/runtime/artifacts/source-build/self/src/ /p:ArtifactsDir=/root/jenkins-scripts/ci/check_sb/dotnet/src/runtime/artifacts/source-build/self/src/artifacts/ /bl:/root/jenkins-scripts/ci/check_sb/dotnet/src/runtime/artifacts/source-build/self/src/artifacts/sourcebuild.binlog /p:ContinuousIntegrationBuild=true /p:SourceBuildOutputDir=/root/jenkins-scripts/ci/check_sb/dotnet/src/runtime/artifacts/source-build/ /p:SourceBuiltBlobFeedDir= /p:DotNetBuildOffline=true /p:DotNetPackageVersionPropsPath=/root/jenkins-scripts/ci/check_sb/dotnet/artifacts/obj/x64/Release/PackageVersions.runtime.props /p:FullAssemblySigningSupported=false" exited with code 1.

  Build FAILED.

@uweigand
Copy link

uweigand commented Aug 9, 2023

Hi @MichaelSimons it seems this failure happens in or near the IsXmlException routine that already caused problems during our initial 6.0 build due to .NET Framework 4.7 dependencies described here: #2618

The message "Failure has occurred while loading a type." also sounds suspiciously like the above problem.

Not sure if this is just a coincidence or if that problem is coming back somehow?

@tmds
Copy link
Member

tmds commented Aug 22, 2023

As was said earlier, the issue can be reproduce on x64.
I can reproduce it with an SDK built from https://github.com/dotnet/dotnet release/8.0.1xx branch (with the --use-mono-runtime argument).

With this SDK, the issue can be reproduced by restoring an invalid project file:

  1. Create a new console project:
dotnet new console -o console
  1. Edit the console/console.csproj file to make it invalid, for example add a / on the first line.

Run dotnet restore console.

  1. The restore fails while trying to load some type during NotExpectedIoOrXmlException:
MSBUILD : error : This is an unhandled exception in MSBuild -- PLEASE UPVOTE AN EXISTING ISSUE OR FILE A NEW ONE AT https://aka.ms/msbuild/unhandled [/tmp/repro/console/console.csproj]
MSBUILD : error :     System.TypeLoadException: Failure has occurred while loading a type. [/tmp/repro/console/console.csproj]
MSBUILD : error :    at Microsoft.Build.Shared.ExceptionHandling.NotExpectedIoOrXmlException(Exception e) [/tmp/repro/console/console.csproj]
MSBUILD : error :    at Microsoft.Build.Construction.ProjectRootElement.LoadDocument(String fullPath, Boolean preserveFormatting, Boolean loadAsReadOnly) [/tmp/repro/console/console.csproj]
MSBUILD : error :    at Microsoft.Build.Construction.ProjectRootElement..ctor(String path, ProjectRootElementCacheBase projectRootElementCache, Boolean preserveFormatting) [/tmp/repro/console/console.csproj]
MSBUILD : error :    at Microsoft.Build.Construction.ProjectRootElement.CreateProjectFromPath(String projectFile, ProjectRootElementCacheBase projectRootElementCache, Boolean preserveFormatting) [/tmp/repro/console/console.csproj]
MSBUILD : error :    at Microsoft.Build.Construction.ProjectRootElement.<>c.<OpenProjectOrSolution>b__209_0(String path, ProjectRootElementCacheBase cache) [/tmp/repro/console/console.csproj]
MSBUILD : error :    at Microsoft.Build.Evaluation.ProjectRootElementCache.GetOrLoad(String projectFile, OpenProjectRootElement loadProjectRootElement, Boolean isExplicitlyLoaded, Nullable`1 preserveFormatting) [/tmp/repro/console/console.csproj]
MSBUILD : error :    at Microsoft.Build.Evaluation.ProjectRootElementCache.Get(String projectFile, OpenProjectRootElement loadProjectRootElement, Boolean isExplicitlyLoaded, Nullable`1 preserveFormatting) [/tmp/repro/console/console.csproj]
MSBUILD : error :    at Microsoft.Build.Construction.ProjectRootElement.OpenProjectOrSolution(String fullPath, IDictionary`2 globalProperties, String toolsVersion, ProjectRootElementCacheBase projectRootElementCache, Boolean isExplicitlyLoaded) [/tmp/repro/console/console.csproj]
MSBUILD : error :    at Microsoft.Build.Execution.ProjectInstance..ctor(String projectFile, IDictionary`2 globalProperties, String toolsVersion, BuildParameters buildParameters, ILoggingService loggingService, BuildEventContext buildEventContext, ISdkResolverService sdkResolverService, Int32 submissionId, Nullable`1 projectLoadSettings) [/tmp/repro/console/console.csproj]
MSBUILD : error :    at Microsoft.Build.BackEnd.BuildRequestConfiguration.<>c__DisplayClass61_0.<LoadProjectIntoConfiguration>b__0() [/tmp/repro/console/console.csproj]
MSBUILD : error :    at Microsoft.Build.BackEnd.BuildRequestConfiguration.InitializeProject(BuildParameters buildParameters, Func`1 loadProjectFromFile) [/tmp/repro/console/console.csproj]
MSBUILD : error :    at Microsoft.Build.BackEnd.BuildRequestConfiguration.LoadProjectIntoConfiguration(IBuildComponentHost componentHost, BuildRequestDataFlags buildRequestDataFlags, Int32 submissionId, Int32 nodeId) [/tmp/repro/console/console.csproj]
MSBUILD : error :    at Microsoft.Build.BackEnd.RequestBuilder.BuildProject() [/tmp/repro/console/console.csproj]
MSBUILD : error :    at Microsoft.Build.BackEnd.RequestBuilder.BuildAndReport() [/tmp/repro/console/console.csproj]

@akoeplinger @lambdageek can you help debug this further?

@uweigand
Copy link

Hi @tmds we've had some more progress in tracking this down. Enabling Mono logging shows the following failure:

Mono: The following assembly referenced from /root/sb_issue/new_tarball/sdk/8.0.100-preview.6.23330.1/Microsoft.Build.dll could not be loaded:
     Assembly:   System.Security.Permissions    (assemblyref_index=34)
     Version:    7.0.0.0
     Public Key: cc7b13ffcd2ddd51

This is consistent with the error message, as the NotExpectedIoOrXmlException routine references a type that is defined in the System.Security.Permissions assembly. This is the same symptom we saw back in the .NET 6 days - but in those days msbuild was trying to refer to a .NET Framework 4.7 version of System.Security.Permissions.

What is still unclear is why it is looking for the 7.0.0 version here. My understanding is that in source-build, this version string should be overridden to refer to the version built as part of the source-build runtime (i.e. a 8.0.0-preview something version). We are still trying to figure out why there's still a 7.0.0 reference remaining here.

@tmds
Copy link
Member

tmds commented Aug 22, 2023

System.Security.Permissions.

When I disassemble this dll (from the sdk folder), it looks like a reference assembly (throw null; ...), while the corresponding dll from a coreclr build does not.

@uweigand
Copy link

When I disassemble this dll (from the sdk folder), it looks like a reference assembly (throw null; ...), while the corresponding dll from a coreclr build does not.

Interesting ... is the corresponding dll from a coreclr build also version 7.0.0 or something else?

@MichaelSimons
Copy link
Member

What is still unclear is why it is looking for the 7.0.0 version here. My understanding is that in source-build, this version string should be overridden to refer to the version built as part of the source-build runtime (i.e. a 8.0.0-preview something version). We are still trying to figure out why there's still a 7.0.0 reference remaining here.

Source-build no longer overrides all version strings starting in 8.0. Repo's now have the ability to control if they want source-build to utilize the latest or if they want a specific version in which a reference assembly is used. See #2482 for more details.

I would not expect a behavior difference between the CoreCLR and Mono builds however.

@uweigand
Copy link

Source-build no longer overrides all version strings starting in 8.0. Repo's now have the ability to control if they want source-build to utilize the latest or if they want a specific version in which a reference assembly is used. See #2482 for more details.

Huh, I must have missed that. I'm not sure I fully understand how this intended to work with the specific case of the System.Security.Permissions DLL here. Looking at the "normal" build (either our own cross-builds, or the official Microsoft SDK builds), the file that will be installed as

  <dotnet root>/sdk/<version>/System.Security.Permissions.dll

is in fact the assembly from the System.Security.Permissions nuget package for version 7.0.0.

However, in an SDK resulting from a source-build / VMR build, that file cannot be from nuget - and in fact it appears to be just a reference assembly.

But in my understanding these files under sdk/ are supposed to be suitable for execution, not just reference DLLs. Am I missing something here, or how is this supposed to work?

I would not expect a behavior difference between the CoreCLR and Mono builds however.

The one difference is (same as when we saw it with .NET 6) that CoreCLR lazily loads assemblies to resolve types, while Mono is more eager. So it may be that the problem that this assembly cannot be executed simply doesn't show up with CoreCLR as it's never even attempted to be executed ...

@MichaelSimons
Copy link
Member

But in my understanding these files under sdk/ are supposed to be suitable for execution, not just reference DLLs. Am I missing something here, or how is this supposed to work?

The problem is that the repo/project declaring this dependency is utilizing a ref assembly and it should not be. It will need to declare this dependency in the repo's version.details.xml file and mark it with the source-build element. This will trigger source-build to lift it to latest. Do you know where this dependency comes from?

@uweigand
Copy link

But in my understanding these files under sdk/ are supposed to be suitable for execution, not just reference DLLs. Am I missing something here, or how is this supposed to work?

The problem is that the repo/project declaring this dependency is utilizing a ref assembly and it should not be. It will need to declare this dependency in the repo's version.details.xml file and mark it with the source-build element. This will trigger source-build to lift it to latest. Do you know where this dependency comes from?

System.Security.Permissions.dll is required by Microsoft.Build.dll, which is built as part of the msbuild repo.

@tmds
Copy link
Member

tmds commented Aug 22, 2023

The mono sdk has the dll in 3 places:

./sdk/8.0.100-rc.2.23422.1/System.Security.Permissions.dll
./sdk/8.0.100-rc.2.23422.1/Containers/tasks/net8.0/System.Security.Permissions.dll
./sdk/8.0.100-rc.2.23422.1/FSharp/System.Security.Permissions.dll

All 3 have the reference assembly instead of the implementation assembly.

@tmds
Copy link
Member

tmds commented Aug 22, 2023

When I disassemble this dll (from the sdk folder), it looks like a reference assembly (throw null; ...), while the corresponding dll from a coreclr build does not.

Correction: I was comparing to the Microsoft build which has the implementation assembly.

A source-built SDK with CoreCLR also has the reference assembly.

As @uweigand mentioned, probably it doesn't effectively try to load the assembly to perform the type check in NotExpectedIoOrXmlException.

@uweigand
Copy link

All 3 have the reference assembly instead of the implementation assembly.

Ah, good point. But as far as I can see, all those dependencies on System.Security.Permissions.dll come from some Microsoft.Build*.dll assembly, either directly or indirectly via System.Configuration.ConfigurationManager. So it's probably still all about the msbuild repo.

@mthalman
Copy link
Member

probably it doesn't effectively try to load the assembly to perform the type check in

That doesn't surprise me at all. Unfortunately, the SDK contains a fair number of assemblies that don't get loaded.

@mthalman mthalman self-assigned this Aug 23, 2023
@mthalman mthalman moved this from 8.0 GA to In Progress in .NET Source Build Aug 23, 2023
@mthalman
Copy link
Member

I have a fix for MSBuild's reference to System.Security.Permissions. It allows the repro described in #3571 (comment) to properly report the syntax error. I'll link the fix to here once I get it out.

@tmds
Copy link
Member

tmds commented Aug 24, 2023

There may be a few additional cases to tackle. These are the sdk assemblies that are ref assemblies on source-build and implementation assemblies in the Microsoft build:

sdk/8.0.100-preview.7.23376.1/Microsoft.Win32.SystemEvents.dll
sdk/8.0.100-preview.7.23376.1/System.ComponentModel.Composition.dll
sdk/8.0.100-preview.7.23376.1/System.Drawing.Common.dll
sdk/8.0.100-preview.7.23376.1/System.Security.Permissions.dll
sdk/8.0.100-preview.7.23376.1/System.Windows.Extensions.dll
sdk/8.0.100-preview.7.23376.1/FSharp/Microsoft.Win32.SystemEvents.dll
sdk/8.0.100-preview.7.23376.1/FSharp/System.CodeDom.dll
sdk/8.0.100-preview.7.23376.1/FSharp/System.Drawing.Common.dll
sdk/8.0.100-preview.7.23376.1/FSharp/System.Resources.Extensions.dll
sdk/8.0.100-preview.7.23376.1/FSharp/System.Security.Cryptography.Xml.dll
sdk/8.0.100-preview.7.23376.1/FSharp/System.Security.Permissions.dll
sdk/8.0.100-preview.7.23376.1/FSharp/System.Windows.Extensions.dll
sdk/8.0.100-preview.7.23376.1/DotnetTools/dotnet-format/Microsoft.Extensions.DependencyInjection.Abstractions.dll
sdk/8.0.100-preview.7.23376.1/DotnetTools/dotnet-format/Microsoft.Extensions.DependencyInjection.dll
sdk/8.0.100-preview.7.23376.1/DotnetTools/dotnet-format/Microsoft.Extensions.FileSystemGlobbing.dll
sdk/8.0.100-preview.7.23376.1/DotnetTools/dotnet-format/Microsoft.Extensions.Logging.Abstractions.dll
sdk/8.0.100-preview.7.23376.1/DotnetTools/dotnet-format/Microsoft.Extensions.Logging.dll
sdk/8.0.100-preview.7.23376.1/DotnetTools/dotnet-format/Microsoft.Extensions.Options.dll
sdk/8.0.100-preview.7.23376.1/DotnetTools/dotnet-format/Microsoft.Extensions.Primitives.dll
sdk/8.0.100-preview.7.23376.1/DotnetTools/dotnet-format/System.IO.Pipelines.dll
sdk/8.0.100-preview.7.23376.1/Containers/tasks/net8.0/Microsoft.Win32.SystemEvents.dll
sdk/8.0.100-preview.7.23376.1/Containers/tasks/net8.0/System.Drawing.Common.dll
sdk/8.0.100-preview.7.23376.1/Containers/tasks/net8.0/System.Security.Permissions.dll
sdk/8.0.100-preview.7.23376.1/Containers/tasks/net8.0/System.Windows.Extensions.dll

@Sapana-Khemkar
Copy link

I have a fix for MSBuild's reference to System.Security.Permissions. It allows the repro described in #3571 (comment) to properly report the syntax error. I'll link the fix to here once I get it out.

Verified patch on ppc64le VM and found issue is fixed

@MichaelSimons
Copy link
Member

FYI - #2817 is a related tracking issue that will enhance our infrastructure to detect reference packages being getting bundled in the output.

JaynieBai pushed a commit to dotnet/msbuild that referenced this issue Aug 25, 2023
)

When .NET is source-built with the mono runtime, there can be scenarios where MSBuild is made to attempt to load a reference assembly for System.Security.Permissions. See dotnet/source-build#3571 (comment) for such a scenario.

The reason a reference assembly exists in this case is because MSBuild has a reference to the 7.0.0 version of System.Security.Permissions. When building with source-build, it loads that reference from SBRP (which only contains reference assemblies) in order to fulfill compile time references. The problem is that the assembly is also getting included in the output. This should have been detected by poison leak detection but that doesn't yet handle reference assemblies.

The solution is to update Version.Details so that the "live" version of System.Security.Permissions, that was previously built with source-build, will flow to the build of the MSBuild repo. Essentially, this causes the SystemSecurityPermissionsVersion property to be overridden with the live version.

Fixes dotnet/source-build#3571
dotnet-bot pushed a commit to dotnet/dotnet that referenced this issue Aug 25, 2023
…ons for source-build (#9158)

When .NET is source-built with the mono runtime, there can be scenarios where MSBuild is made to attempt to load a reference assembly for System.Security.Permissions. See dotnet/source-build#3571 (comment) for such a scenario.

The reason a reference assembly exists in this case is because MSBuild has a reference to the 7.0.0 version of System.Security.Permissions. When building with source-build, it loads that reference from SBRP (which only contains reference assemblies) in order to fulfill compile time references. The problem is that the assembly is also getting included in the output. This should have been detected by poison leak detection but that doesn't yet handle reference assemblies.

The solution is to update Version.Details so that the "live" version of System.Security.Permissions, that was previously built with source-build, will flow to the build of the MSBuild repo. Essentially, this causes the SystemSecurityPermissionsVersion property to be overridden with the live version.

Fixes dotnet/source-build#3571

Original commit: dotnet/msbuild@be26b4c

[[ commit created by automation ]]
@tmds
Copy link
Member

tmds commented Aug 28, 2023

The preview can be built using this patch: dotnet/msbuild#9158.

Looking into the other reference assemblies is tracked by #3599.

@tmds tmds closed this as completed Aug 28, 2023
@github-project-automation github-project-automation bot moved this from In Progress to Done in .NET Source Build Aug 28, 2023
@MichaelSimons
Copy link
Member

@tmds - regarding Looking into the other reference assemblies is tracked by #3599., Matt already has PRs opened that addresses these.

NikolaMilosavljevic pushed a commit to dotnet/dotnet that referenced this issue Oct 10, 2023
…ons for source-build (#9158)

When .NET is source-built with the mono runtime, there can be scenarios where MSBuild is made to attempt to load a reference assembly for System.Security.Permissions. See dotnet/source-build#3571 (comment) for such a scenario.

The reason a reference assembly exists in this case is because MSBuild has a reference to the 7.0.0 version of System.Security.Permissions. When building with source-build, it loads that reference from SBRP (which only contains reference assemblies) in order to fulfill compile time references. The problem is that the assembly is also getting included in the output. This should have been detected by poison leak detection but that doesn't yet handle reference assemblies.

The solution is to update Version.Details so that the "live" version of System.Security.Permissions, that was previously built with source-build, will flow to the build of the MSBuild repo. Essentially, this causes the SystemSecurityPermissionsVersion property to be overridden with the live version.

Fixes dotnet/source-build#3571

Original commit: dotnet/msbuild@be26b4c

[[ commit created by automation ]]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-upstream-fix Needs a change in a contributing repo
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

7 participants