public static void RegisterDefaultInstance(this IMSBuildLocator msbuildLocator, ILogger logger)
        {
            var bestInstanceFound = GetBestInstance(msbuildLocator, logger, out var invalidVSFound, out var vsWithoutSdkResolver);

            if (bestInstanceFound != null)
            {
                // Did we end up choosing the standalone MSBuild because there was an invalid Visual Studio?
                // If so, provide a helpful message to the user.
                if (invalidVSFound && bestInstanceFound.DiscoveryType == DiscoveryType.StandAlone)
                {
                    logger.LogWarning(
                        @"It looks like you have Visual Studio lower than VS 2019 16.3 installed.
 Try updating Visual Studio to the most recent release to enable better MSBuild support."
                        );
                }

                if (vsWithoutSdkResolver && bestInstanceFound.DiscoveryType == DiscoveryType.StandAlone)
                {
                    logger.LogWarning(
                        @"It looks like you have Visual Studio 2019 installed without .NET Core SDK support which is required by OmniSharp.
 Try updating Visual Studio 2019 installation with .NET Core SDK to enable better MSBuild support."
                        );
                }

                msbuildLocator.RegisterInstance(bestInstanceFound);
            }
            else
            {
                logger.LogError("Could not locate MSBuild instance to register with OmniSharp");
            }
        }
Example #2
0
        public static void RegisterDefaultInstance(this IMSBuildLocator msbuildLocator, ILogger logger, DotNetInfo dotNetInfo = null)
        {
            var minimumMSBuildVersion = GetSdkMinimumMSBuildVersion(dotNetInfo, logger);

            logger.LogDebug($".NET SDK requires MSBuild instances version {minimumMSBuildVersion} or higher");

            var bestInstanceFound = GetBestInstance(msbuildLocator, minimumMSBuildVersion, logger, out var invalidVSFound, out var vsWithoutSdkResolver);

            if (bestInstanceFound != null)
            {
                if (bestInstanceFound.Version < minimumMSBuildVersion)
                {
                    if (bestInstanceFound.DiscoveryType == DiscoveryType.Mono)
                    {
                        logger.LogWarning(
                            $@"It looks like you have Mono installed which contains a MSBuild lower than {minimumMSBuildVersion} which is the minimum supported by the configured .NET Core Sdk.
 Try updating Mono to the latest stable or preview version to enable better .NET Core Sdk support."
                            );
                    }
                    else if (bestInstanceFound.DiscoveryType == DiscoveryType.VisualStudioSetup)
                    {
                        logger.LogWarning(
                            $@"It looks like you have Visual Studio 2019 installed which contains a MSBuild lower than {minimumMSBuildVersion} which is the minimum supported by the configured .NET Core Sdk.
 Try updating Visual Studio to version {minimumMSBuildVersion} or higher to enable better .NET Core Sdk support."
                            );
                    }
                    else if (bestInstanceFound.DiscoveryType == DiscoveryType.UserOverride)
                    {
                        logger.LogWarning(
                            $@"It looks like you have overridden the version of MSBuild with a version lower than {minimumMSBuildVersion} which is the minimum supported by the configured .NET Core Sdk.
 Try updating your MSBuild to version {minimumMSBuildVersion} or higher to enable better .NET Core Sdk support."
                            );
                    }
                }

                msbuildLocator.RegisterInstance(bestInstanceFound);
            }
            else
            {
                throw new MSBuildNotFoundException("Could not locate MSBuild instance to register with OmniSharp.");
            }
        }
Example #3
0
        public static void RegisterDefaultInstance(this IMSBuildLocator msbuildLocator, ILogger logger)
        {
            var bestInstanceFound = GetBestInstance(msbuildLocator, out var invalidVSFound);

            if (bestInstanceFound != null)
            {
                // Did we end up choosing the standalone MSBuild because there was an invalid Visual Studio?
                // If so, provide a helpful message to the user.
                if (invalidVSFound && bestInstanceFound.DiscoveryType == DiscoveryType.StandAlone)
                {
                    logger.LogWarning(
                        @"It looks like you have Visual Studio 2017 RTM installed.
 Try updating Visual Studio 2017 to the most recent release to enable better MSBuild support."
                        );
                }

                msbuildLocator.RegisterInstance(bestInstanceFound);
            }
            else
            {
                logger.LogError("Could not locate MSBuild instance to register with OmniSharp");
            }
        }
Example #4
0
        private static void RegisterMSBuildInstance(IMSBuildLocator msbuildLocator, ILogger logger)
        {
            MSBuildInstance instanceToRegister = null;
            var             invalidVSFound     = false;

            foreach (var instance in msbuildLocator.GetInstances())
            {
                if (instance.IsInvalidVisualStudio())
                {
                    invalidVSFound = true;
                }
                else
                {
                    instanceToRegister = instance;
                    break;
                }
            }


            if (instanceToRegister != null)
            {
                // Did we end up choosing the standalone MSBuild because there was an invalid Visual Studio?
                // If so, provide a helpful message to the user.
                if (invalidVSFound && instanceToRegister.DiscoveryType == DiscoveryType.StandAlone)
                {
                    logger.LogWarning(@"It looks like you have Visual Studio 2017 RTM installed.
Try updating Visual Studio 2017 to the most recent release to enable better MSBuild support.");
                }

                msbuildLocator.RegisterInstance(instanceToRegister);
            }
            else
            {
                logger.LogError("Could not locate MSBuild instance to register with OmniSharp");
            }
        }
Example #5
0
        public static void RegisterDefaultInstance(this IMSBuildLocator msbuildLocator, ILogger logger, DotNetInfo dotNetInfo = null)
        {
            var minimumMSBuildVersion = GetSdkMinimumMSBuildVersion(dotNetInfo, logger);

            logger.LogDebug($".NET SDK requires MSBuild instances version {minimumMSBuildVersion} or higher");

            var bestInstanceFound = GetBestInstance(msbuildLocator, minimumMSBuildVersion, logger, out var invalidVSFound, out var vsWithoutSdkResolver);

            if (bestInstanceFound != null)
            {
                // Did we end up choosing the standalone MSBuild because there was an invalid Visual Studio?
                // If so, provide a helpful message to the user.
                if (invalidVSFound && bestInstanceFound.DiscoveryType == DiscoveryType.StandAlone)
                {
                    logger.LogWarning(
                        $@"It looks like you have Visual Studio lower than VS 2019 {s_minimumMSBuildVersion} installed.
 Try updating Visual Studio to the most recent release to enable better MSBuild support."
                        );
                }

                if (vsWithoutSdkResolver && bestInstanceFound.DiscoveryType == DiscoveryType.StandAlone)
                {
                    logger.LogWarning(
                        @"It looks like you have Visual Studio 2019 installed without .NET Core SDK support which is required by OmniSharp.
 Try updating Visual Studio 2019 installation with .NET Core SDK to enable better MSBuild support."
                        );
                }

                if (bestInstanceFound.Version < minimumMSBuildVersion)
                {
                    if (bestInstanceFound.DiscoveryType == DiscoveryType.StandAlone)
                    {
                        logger.LogWarning(
                            $@"It looks like the included version of MSBuild is lower than {minimumMSBuildVersion} which is the minimum supported by the configured .NET Core Sdk.
 Try installing MSBuild version {minimumMSBuildVersion} or higher to enable better .NET Core Sdk support."
                            );
                    }
                    else if (bestInstanceFound.DiscoveryType == DiscoveryType.Mono)
                    {
                        logger.LogWarning(
                            $@"It looks like you have Mono installed which contains a MSBuild lower than {minimumMSBuildVersion} which is the minimum supported by the configured .NET Core Sdk.
 Try updating Mono to the latest stable or preview version to enable better .NET Core Sdk support."
                            );
                    }
                    else if (bestInstanceFound.DiscoveryType == DiscoveryType.VisualStudioSetup)
                    {
                        logger.LogWarning(
                            $@"It looks like you have Visual Studio 2019 installed which contains a MSBuild lower than {minimumMSBuildVersion} which is the minimum supported by the configured .NET Core Sdk.
 Try updating Visual Studio to version {minimumMSBuildVersion} or higher to enable better .NET Core Sdk support."
                            );
                    }
                    else if (bestInstanceFound.DiscoveryType == DiscoveryType.UserOverride)
                    {
                        logger.LogWarning(
                            $@"It looks like you have overridden the version of MSBuild with a version lower than {minimumMSBuildVersion} which is the minimum supported by the configured .NET Core Sdk.
 Try updating your MSBuild to version {minimumMSBuildVersion} or higher to enable better .NET Core Sdk support."
                            );
                    }
                }

                msbuildLocator.RegisterInstance(bestInstanceFound);
            }
            else
            {
                throw new MSBuildNotFoundException("Could not locate MSBuild instance to register with OmniSharp.");
            }
        }