public static int Main()

in src/Microsoft.VisualStudio.SlnGen/Program.cs [57:119]


        public static int Main(string[] args)
        {
            CurrentDevelopmentEnvironment = DevelopmentEnvironment.LoadCurrentDevelopmentEnvironment();

            if (!CurrentDevelopmentEnvironment.Success || CurrentDevelopmentEnvironment.Errors.Count > 0)
            {
                foreach (string error in CurrentDevelopmentEnvironment.Errors)
                {
                    Utility.WriteError(error);
                }

                return -1;
            }

            Assembly thisAssembly = Assembly.GetExecutingAssembly();

#if NETFRAMEWORK
            if (AppDomain.CurrentDomain.IsDefaultAppDomain())
            {
                AppDomain appDomain = AppDomain.CreateDomain(
                    thisAssembly.FullName,
                    securityInfo: null,
                    info: new AppDomainSetup
                    {
                        ApplicationBase = CurrentDevelopmentEnvironment.MSBuildExe.DirectoryName,
                        ConfigurationFile = Path.Combine(CurrentDevelopmentEnvironment.MSBuildExe.DirectoryName!, Path.ChangeExtension(CurrentDevelopmentEnvironment.MSBuildExe.Name, ".exe.config")),
                    });

                return appDomain
                    .ExecuteAssembly(
                        thisAssembly.Location,
                        args);
            }
#endif
            FileInfo thisAssemblyFileInfo = new FileInfo(thisAssembly.Location);

            AppDomain.CurrentDomain.AssemblyResolve += (sender, eventArgs) =>
            {
                AssemblyName requestedAssemblyName = new AssemblyName(eventArgs.Name);

#if NETFRAMEWORK
                FileInfo candidateAssemblyFileInfo = new FileInfo(Path.Combine(thisAssemblyFileInfo.DirectoryName, $"{requestedAssemblyName.Name}.dll"));
#else
                FileInfo candidateAssemblyFileInfo = new FileInfo(Path.Combine(CurrentDevelopmentEnvironment.MSBuildDll.DirectoryName!, $"{requestedAssemblyName.Name}.dll"));
#endif
                if (!candidateAssemblyFileInfo.Exists)
                {
                    return null;
                }

                AssemblyName candidateAssemblyName = AssemblyName.GetAssemblyName(candidateAssemblyFileInfo.FullName);

                if ((requestedAssemblyName.ProcessorArchitecture != ProcessorArchitecture.None && requestedAssemblyName.ProcessorArchitecture != candidateAssemblyName.ProcessorArchitecture)
                    || (requestedAssemblyName.Flags.HasFlag(AssemblyNameFlags.PublicKey) && !requestedAssemblyName.GetPublicKeyToken() !.SequenceEqual(candidateAssemblyName.GetPublicKeyToken() !)))
                {
                    return null;
                }

                return Assembly.LoadFrom(candidateAssemblyFileInfo.FullName);
            };

            return Execute(args, PhysicalConsole.Singleton);
        }