コード例 #1
0
        private void OpenSourceCode(Assembly assembly)
        {
            string[] projectpath = assembly.FullName.Split(',');
            var      folder      = projectpath[0].Split('.')[1].Replace("demos", "");

            if (folder == "chart")
            {
                folder = folder + "s";
            }
            string frameworkVersion = new System.Runtime.Versioning.FrameworkName(AppDomain.CurrentDomain.SetupInformation.TargetFrameworkName).Version.ToString();

            frameworkVersion = frameworkVersion.ToString().Replace(".", string.Empty);
            string project = projectpath[0] + "_" + frameworkVersion + ".sln";
            string root    = System.IO.Path.GetFullPath(System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"..\\..\\" + folder + "\\" + project));

            if (!File.Exists(root))
            {
                return;
            }
            try
            {
                var process = new ProcessStartInfo
                {
                    FileName        = root,
                    UseShellExecute = true
                };
                Process.Start(process);
            }
            catch (Exception e)
            {
                ErrorLogging.LogError("Requested directory not found." + "\n" + e.Message + "\n" + e.StackTrace);
            }
        }
コード例 #2
0
        public void TestGeneralFrameworkMonikerGoodWithInvalidCharInIncludePath()
        {
            string tempDirectory        = Path.Combine(Path.GetTempPath(), "TestGeneralFrameworkMonikerGoodWithInvalidCharInIncludePath");
            string framework41Directory = Path.Combine(tempDirectory, Path.Combine("MyFramework", "v4.1") + Path.DirectorySeparatorChar);
            string redistListDirectory  = Path.Combine(framework41Directory, "RedistList");
            string redistListFile       = Path.Combine(redistListDirectory, "FrameworkList.xml");

            try
            {
                Directory.CreateDirectory(framework41Directory);
                Directory.CreateDirectory(redistListDirectory);

                string redistListContents =
                    "<FileList Redist='Microsoft-Windows-CLRCoreComp' IncludeFramework='v4.*' Name='Chained oh noes'>" +
                    "<File AssemblyName='System.Xml' Version='2.0.0.0' PublicKeyToken='b03f5f7f11d50a3a' Culture='Neutral' FileVersion='2.0.50727.208' InGAC='true' />" +
                    "<File AssemblyName='Microsoft.Build.Engine' Version='2.0.0.0' PublicKeyToken='b03f5f7f11d50a3a' Culture='Neutral' FileVersion='2.0.50727.208' InGAC='true' />" +
                    "</FileList >";

                File.WriteAllText(redistListFile, redistListContents);

                string     targetFrameworkMoniker = "MyFramework, Version=v4.1";
                MockEngine engine = new MockEngine();
                GetReferenceAssemblyPaths getReferencePaths = new GetReferenceAssemblyPaths();
                getReferencePaths.BuildEngine            = engine;
                getReferencePaths.TargetFrameworkMoniker = targetFrameworkMoniker;
                getReferencePaths.RootPath = tempDirectory;
                getReferencePaths.Execute();
                string[] returnedPaths = getReferencePaths.ReferenceAssemblyPaths;
                Assert.Empty(returnedPaths);
                string displayName = getReferencePaths.TargetFrameworkMonikerDisplayName;
                Assert.Null(displayName);
                FrameworkNameVersioning frameworkMoniker = new FrameworkNameVersioning(getReferencePaths.TargetFrameworkMoniker);
                if (NativeMethodsShared.IsWindows)
                {
                    engine.AssertLogContains("MSB3643");
                }
                else
                {
                    // Since under Unix there are no invalid characters, we don't fail in the incorrect path
                    // and go through to actually looking for the directory
                    string message =
                        ResourceUtilities.FormatResourceStringStripCodeAndKeyword(
                            "GetReferenceAssemblyPaths.NoReferenceAssemblyDirectoryFound",
                            frameworkMoniker.ToString());
                    engine.AssertLogContains(message);
                }
            }
            finally
            {
                if (Directory.Exists(framework41Directory))
                {
                    FileUtilities.DeleteWithoutTrailingBackslash(framework41Directory, true);
                }
            }
        }
コード例 #3
0
 protected override void Invoke(object parameter)
 {
     if (parameter is RoutedEventArgs)
     {
         string frameworkVersion = new System.Runtime.Versioning.FrameworkName(AppDomain.CurrentDomain.SetupInformation.TargetFrameworkName).Version.ToString();
         frameworkVersion = frameworkVersion.ToString().Replace(".", string.Empty);
         RoutedEventArgs eventArgs = parameter as RoutedEventArgs;
         Button          button    = eventArgs.OriginalSource as Button;
         if (AppDomain.CurrentDomain.BaseDirectory.Contains("Binaries_" + frameworkVersion))
         {
             button.Visibility = Visibility.Visible;
         }
     }
 }
コード例 #4
0
        private void OpenSourceCode(Assembly assembly, string buttonName)
        {
            string[] projectpath      = assembly.FullName.Split(',');
            var      folder           = projectpath[0].Split('.')[1].Replace("demos", "");
            string   frameworkVersion = "";
            string   project          = "";
            string   root             = "";

            if (buttonName == "openvisualstudio")
            {
                frameworkVersion = new System.Runtime.Versioning.FrameworkName(AppDomain.CurrentDomain.SetupInformation.TargetFrameworkName).Version.ToString();
                frameworkVersion = frameworkVersion.ToString().Replace(".", string.Empty);
                project          = projectpath[0] + "_" + frameworkVersion + ".sln";
                root             = System.IO.Path.GetFullPath(System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"..\\..\\" + folder + "\\" + project));
            }
            else if (buttonName == "opengithub")
            {
                root = "https://github.com/syncfusion/wpf-demos/tree/master/" + folder;
            }

            if (!File.Exists(root) && buttonName == "openvisualstudio")
            {
                return;
            }
            try
            {
                var process = new ProcessStartInfo
                {
                    FileName        = root,
                    UseShellExecute = true
                };
                Process.Start(process);
            }
            catch (Exception exception)
            {
                if (Application.Current.Windows[0].DataContext != null)
                {
                    var viewModel = Application.Current.Windows[0].DataContext as DemoBrowserViewModel;
                    if (viewModel.SelectedProduct != null && viewModel.SelectedSample != null)
                    {
                        ErrorLogging.LogError("Product Sample\\" + viewModel.SelectedProduct.Product + "\\" + viewModel.SelectedSample.SampleName + "@@" + "Requested directory not found." + exception.Message + "\n" + exception.StackTrace + "\n" + exception.Source);
                    }
                    else if (viewModel.SelectedShowcaseSample != null)
                    {
                        ErrorLogging.LogError("Product ShowCase\\" + viewModel.SelectedShowcaseSample.SampleName + "\\" + viewModel.SelectedShowcaseSample.SampleName + "@@" + "Requested directory not found." + exception.Message + "\n" + exception.StackTrace + "\n" + exception.Source);
                    }
                }
            }
        }
コード例 #5
0
 protected override void Invoke(object parameter)
 {
     if (this.AssociatedObject == null)
     {
         return;
     }
     if (DemoBrowserViewModel.IsStoreApp && AssociatedObject.Name == "opengithub")
     {
         AssociatedObject.Visibility = Visibility.Visible;
     }
     else if (!DemoBrowserViewModel.IsStoreApp && AssociatedObject.Name == "openvisualstudio")
     {
         string frameworkVersion = new System.Runtime.Versioning.FrameworkName(AppDomain.CurrentDomain.SetupInformation.TargetFrameworkName).Version.ToString();
         frameworkVersion = frameworkVersion.ToString().Replace(".", string.Empty);
         if (AppDomain.CurrentDomain.BaseDirectory.Contains("Binaries_" + frameworkVersion))
         {
             AssociatedObject.Visibility = Visibility.Visible;
         }
     }
 }
コード例 #6
0
        void InstallPackageDependencies(System.Runtime.Versioning.FrameworkName TargetFramework, IPackage Package)
        {
            if (Package == null)
            {
                throw new ArgumentNullException("Package", "Package cannot be null");
            }
            if (Package.Id.ToLower() == "netstandard.library")
            {
                return;
            }
            // if (Package.Id.ToLower() == "system.net.websockets.client.managed") return;
            if (Package.Id.ToLower() == "system.buffers")
            {
                return;
            }
            if (Package.Id.ToLower() == "system.reflection.emit")
            {
                return;
            }

            //if (Package.Id.ToLower() == "system.net.websockets.client.managed")
            //{
            //    var b = true;
            //}
            try
            {
                IPackage exists = null;
                System.Runtime.Versioning.FrameworkName framework = TargetFramework;
                if (Package == null)
                {
                    return;
                }
                var deps = Package.GetCompatiblePackageDependencies(framework);
                if (deps.Count() == 0)
                {
                    var dsets = Package.DependencySets.Where(x => x.TargetFramework.Version.Major == 4).OrderByDescending(x => x.TargetFramework.Version.Minor).ToList();
                    if (dsets.Count() == 0 && Package.DependencySets.Count() == 1)
                    {
                        dsets = Package.DependencySets.ToList();
                    }
                    if (dsets.Count() > 0)
                    {
                        if (dsets.First().Dependencies.Count() > 0)
                        {
                            framework = dsets.First().TargetFramework;
                            System.Diagnostics.Debug.WriteLine("******** " + Package.Id + " " + framework.ToString());
                            deps = dsets.First().Dependencies;
                        }
                    }
                    //// .NETFramework4.5
                    //framework = new System.Runtime.Versioning.FrameworkName(".NETStandard", new Version("2.0"));
                    //deps = Package.GetCompatiblePackageDependencies(framework);
                    //if(deps.Count() > 0)
                    //{
                    //    System.Diagnostics.Debug.WriteLine("******** " + Package.Id + " " + framework.ToString());
                    //}
                }
                else
                {
                    System.Diagnostics.Debug.WriteLine("******** " + Package.Id + " " + TargetFramework.ToString());
                    foreach (var d in deps)
                    {
                        System.Diagnostics.Debug.WriteLine(d.Id);
                    }
                }
                foreach (var d in deps)
                {
                    _InstallPackage(d.Id, d.VersionSpec.MinVersion);
                    // Whats wrong with FastMember.1.5.0 ??
                    exists = packageManager.LocalRepository.FindPackage(d.Id);
                    // exists = packageManager.LocalRepository.FindPackage(d.Id, d.VersionSpec.MinVersion);
                    if (exists != null)
                    {
                        PackageInstalled(null, new PackageOperationEventArgs(exists, FileSystem, RepositoryPath + @"\" + exists.Id + "." + exists.Version.ToString()));
                        InstallPackageDependencies(framework, exists);
                    }
                }
            }
            catch (Exception ex)
            {
                logger.Log(MessageLevel.Error, ex.ToString());
                System.Diagnostics.Debug.WriteLine(ex.ToString());
                throw;
            }
        }
コード例 #7
0
        /// <summary>
        /// Generate the set of chained reference assembly paths
        /// </summary>
        private IList <String> GetPaths(string rootPath, string targetFrameworkFallbackSearchPaths, FrameworkNameVersioning frameworkmoniker)
        {
            IList <String> pathsToReturn = ToolLocationHelper.GetPathToReferenceAssemblies(
                frameworkmoniker.Identifier,
                frameworkmoniker.Version.ToString(),
                frameworkmoniker.Profile,
                rootPath,
                targetFrameworkFallbackSearchPaths);

            if (!SuppressNotFoundError)
            {
                // No reference assembly paths could be found, log an error so an invalid build will not be produced.
                // 1/26/16: Note this was changed from a warning to an error (see GitHub #173).
                if (pathsToReturn.Count == 0)
                {
                    // Fixes bad error message when an old SDK assumes "net50" means ".NETFramework 5.0" instead of "netcoreapp 5.0"
                    // https://github.com/dotnet/msbuild/issues/5820
                    if (frameworkmoniker.Identifier == ".NETFramework" && frameworkmoniker.Version.Major >= 5)
                    {
                        Log.LogErrorWithCodeFromResources("GetReferenceAssemblyPaths.OutOfDateSDK", frameworkmoniker.ToString());
                    }
                    else
                    {
                        Log.LogErrorWithCodeFromResources("GetReferenceAssemblyPaths.NoReferenceAssemblyDirectoryFound", frameworkmoniker.ToString());
                    }
                }
            }

            return(pathsToReturn);
        }
コード例 #8
0
        /// <summary>
        /// Generate the set of chained reference assembly paths
        /// </summary>
        private IList <String> GetPaths(string rootPath, FrameworkNameVersioning frameworkmoniker)
        {
            IList <String> pathsToReturn = null;

            if (String.IsNullOrEmpty(rootPath))
            {
                pathsToReturn = ToolLocationHelper.GetPathToReferenceAssemblies(frameworkmoniker);
            }
            else
            {
                pathsToReturn = ToolLocationHelper.GetPathToReferenceAssemblies(rootPath, frameworkmoniker);
            }

            // No reference assembly paths could be found, log a warning as there could be future errors which may be confusing because of this.
            if (pathsToReturn.Count == 0)
            {
                Log.LogWarningWithCodeFromResources("GetReferenceAssemblyPaths.NoReferenceAssemblyDirectoryFound", frameworkmoniker.ToString());
            }

            return(pathsToReturn);
        }
コード例 #9
0
        public void TestGeneralFrameworkMonikerGoodWithInvalidIncludePath()
        {
            string tempDirectory        = Path.Combine(Path.GetTempPath(), "TestGeneralFrameworkMonikerGoodWithInvalidIncludePath");
            string framework41Directory = Path.Combine(tempDirectory, "MyFramework\\v4.1\\");
            string redistListDirectory  = Path.Combine(framework41Directory, "RedistList");
            string redistListFile       = Path.Combine(redistListDirectory, "FrameworkList.xml");

            try
            {
                Directory.CreateDirectory(framework41Directory);
                Directory.CreateDirectory(redistListDirectory);

                string redistListContents =
                    "<FileList Redist='Microsoft-Windows-CLRCoreComp' IncludeFramework='..\\Mooses' Name='Chained oh noes'>" +
                    "<File AssemblyName='System.Xml' Version='2.0.0.0' PublicKeyToken='b03f5f7f11d50a3a' Culture='Neutral' FileVersion='2.0.50727.208' InGAC='true' />" +
                    "<File AssemblyName='Microsoft.Build.Engine' Version='2.0.0.0' PublicKeyToken='b03f5f7f11d50a3a' Culture='Neutral' FileVersion='2.0.50727.208' InGAC='true' />" +
                    "</FileList >";

                File.WriteAllText(redistListFile, redistListContents);

                string     targetFrameworkMoniker = "MyFramework, Version=v4.1";
                MockEngine engine = new MockEngine();
                GetReferenceAssemblyPaths getReferencePaths = new GetReferenceAssemblyPaths();
                getReferencePaths.BuildEngine            = engine;
                getReferencePaths.TargetFrameworkMoniker = targetFrameworkMoniker;
                getReferencePaths.RootPath = tempDirectory;
                getReferencePaths.Execute();
                string[] returnedPaths = getReferencePaths.ReferenceAssemblyPaths;
                Assert.Equal(0, returnedPaths.Length);
                string displayName = getReferencePaths.TargetFrameworkMonikerDisplayName;
                Assert.Null(displayName);
                FrameworkNameVersioning frameworkMoniker = new FrameworkNameVersioning(getReferencePaths.TargetFrameworkMoniker);
                string message = ResourceUtilities.FormatResourceString("GetReferenceAssemblyPaths.NoReferenceAssemblyDirectoryFound", frameworkMoniker.ToString());
                engine.AssertLogContains(message);
            }
            finally
            {
                if (Directory.Exists(framework41Directory))
                {
                    Directory.Delete(framework41Directory, true);
                }
            }
        }
コード例 #10
0
        public void TestGeneralFrameworkMonikerNonExistentOverrideError()
        {
            MockEngine engine = new MockEngine();
            GetReferenceAssemblyPaths getReferencePaths = new GetReferenceAssemblyPaths();

            getReferencePaths.BuildEngine = engine;
            // Make a framework which does not exist, intentional misspelling of framework
            getReferencePaths.TargetFrameworkMoniker = ".NetFramewok, Version=v99.0";

            try
            {
                Environment.SetEnvironmentVariable("MSBUILDWARNONNOREFERENCEASSEMBLYDIRECTORY", "1");
                bool success = getReferencePaths.Execute();
                Assert.True(success);
            }
            finally
            {
                Environment.SetEnvironmentVariable("MSBUILDWARNONNOREFERENCEASSEMBLYDIRECTORY", null);
            }

            string[] returnedPaths = getReferencePaths.ReferenceAssemblyPaths;
            Assert.Equal(0, returnedPaths.Length);
            string displayName = getReferencePaths.TargetFrameworkMonikerDisplayName;

            Assert.Null(displayName);
            FrameworkNameVersioning frameworkMoniker = new FrameworkNameVersioning(getReferencePaths.TargetFrameworkMoniker);
            string message = ResourceUtilities.FormatResourceString("GetReferenceAssemblyPaths.NoReferenceAssemblyDirectoryFound", frameworkMoniker.ToString());

            engine.AssertLogContains("WARNING MSB3644: " + message);
        }
コード例 #11
0
        /// <summary>
        /// Generate the set of chained reference assembly paths
        /// </summary>
        private IList <String> GetPaths(string rootPath, string targetFrameworkFallbackSearchPaths, FrameworkNameVersioning frameworkmoniker)
        {
            string fallbackPathsToUse = (FallbackPathHackOnOSXEnabled && String.IsNullOrEmpty(targetFrameworkFallbackSearchPaths))
                                            ? fallbackPathsToUse = "/Library/Frameworks/Mono.framework/External/xbuild-frameworks"
                                            : targetFrameworkFallbackSearchPaths;


            IList <String> pathsToReturn = ToolLocationHelper.GetPathToReferenceAssemblies(
                frameworkmoniker.Identifier,
                frameworkmoniker.Version.ToString(),
                frameworkmoniker.Profile,
                rootPath,
                fallbackPathsToUse);

            if (!SuppressNotFoundError)
            {
                // No reference assembly paths could be found, log an error so an invalid build will not be produced.
                // 1/26/16: Note this was changed from a warning to an error (see GitHub #173).
                if (pathsToReturn.Count == 0)
                {
                    Log.LogErrorWithCodeFromResources("GetReferenceAssemblyPaths.NoReferenceAssemblyDirectoryFound", frameworkmoniker.ToString());
                }
            }

            return(pathsToReturn);
        }
コード例 #12
0
        /// <summary>
        /// Generate the set of chained reference assembly paths
        /// </summary>
        private IList<String> GetPaths(string rootPath, FrameworkNameVersioning frameworkmoniker)
        {
            IList<String> pathsToReturn = null;

            if (String.IsNullOrEmpty(rootPath))
            {
                pathsToReturn = ToolLocationHelper.GetPathToReferenceAssemblies(frameworkmoniker);
            }
            else
            {
                pathsToReturn = ToolLocationHelper.GetPathToReferenceAssemblies(rootPath, frameworkmoniker);
            }

            // No reference assembly paths could be found, log a warning as there could be future errors which may be confusing because of this.
            if (pathsToReturn.Count == 0)
            {
                Log.LogWarningWithCodeFromResources("GetReferenceAssemblyPaths.NoReferenceAssemblyDirectoryFound", frameworkmoniker.ToString());
            }

            return pathsToReturn;
        }
コード例 #13
0
        /// <summary>
        /// Generate the set of chained reference assembly paths
        /// </summary>
        private IList <String> GetPaths(string rootPath, FrameworkNameVersioning frameworkmoniker)
        {
            IList <String> pathsToReturn = null;

            if (String.IsNullOrEmpty(rootPath))
            {
                pathsToReturn = ToolLocationHelper.GetPathToReferenceAssemblies(frameworkmoniker);
            }
            else
            {
                pathsToReturn = ToolLocationHelper.GetPathToReferenceAssemblies(rootPath, frameworkmoniker);
            }

            // No reference assembly paths could be found, log an error so an invalid build will not be produced.
            // 1/26/16: Note this was changed from a warning to an error (see GitHub #173). Also added the escape hatch
            // (set MSBUILDWARNONNOREFERENCEASSEMBLYDIRECTORY = 1) in case this causes issues.
            // TODO: This should be removed for Dev15
            if (pathsToReturn.Count == 0)
            {
                var warn = Environment.GetEnvironmentVariable(WARNONNOREFERENCEASSEMBLYDIRECTORY);

                if (string.Equals(warn, "1", StringComparison.Ordinal))
                {
                    Log.LogWarningWithCodeFromResources("GetReferenceAssemblyPaths.NoReferenceAssemblyDirectoryFound", frameworkmoniker.ToString());
                }
                else
                {
                    Log.LogErrorWithCodeFromResources("GetReferenceAssemblyPaths.NoReferenceAssemblyDirectoryFound", frameworkmoniker.ToString());
                }
            }

            return(pathsToReturn);
        }
コード例 #14
0
ファイル: GetReferenceAssemblyPaths.cs プロジェクト: 3F/IeXod
        /// <summary>
        /// Generate the set of chained reference assembly paths
        /// </summary>
        private IList <String> GetPaths(string rootPath, string targetFrameworkFallbackSearchPaths, FrameworkNameVersioning frameworkmoniker)
        {
            IList <String> pathsToReturn = ToolLocationHelper.GetPathToReferenceAssemblies(
                frameworkmoniker.Identifier,
                frameworkmoniker.Version.ToString(),
                frameworkmoniker.Profile,
                rootPath,
                targetFrameworkFallbackSearchPaths);

            if (!SuppressNotFoundError)
            {
                // No reference assembly paths could be found, log an error so an invalid build will not be produced.
                // 1/26/16: Note this was changed from a warning to an error (see GitHub #173).
                if (pathsToReturn.Count == 0)
                {
                    Log.LogErrorWithCodeFromResources("GetReferenceAssemblyPaths.NoReferenceAssemblyDirectoryFound", frameworkmoniker.ToString());
                }
            }

            return(pathsToReturn);
        }
コード例 #15
0
 public void TestGeneralFrameworkMonikerNonExistentOverrideError()
 {
     MockEngine engine = new MockEngine();
     GetReferenceAssemblyPaths getReferencePaths = new GetReferenceAssemblyPaths();
     getReferencePaths.BuildEngine = engine;
     // Make a framework which does not exist, intentional misspelling of framework
     getReferencePaths.TargetFrameworkMoniker = ".NetFramewok, Version=v99.0";
     
     try
     {
         Environment.SetEnvironmentVariable("MSBUILDWARNONNOREFERENCEASSEMBLYDIRECTORY", "1");
         bool success = getReferencePaths.Execute();
         Assert.True(success);
     }
     finally
     {
         Environment.SetEnvironmentVariable("MSBUILDWARNONNOREFERENCEASSEMBLYDIRECTORY", null);
     }
     
     string[] returnedPaths = getReferencePaths.ReferenceAssemblyPaths;
     Assert.Equal(0, returnedPaths.Length);
     string displayName = getReferencePaths.TargetFrameworkMonikerDisplayName;
     Assert.Null(displayName);
     FrameworkNameVersioning frameworkMoniker = new FrameworkNameVersioning(getReferencePaths.TargetFrameworkMoniker);
     string message = ResourceUtilities.FormatResourceString("GetReferenceAssemblyPaths.NoReferenceAssemblyDirectoryFound", frameworkMoniker.ToString());
     engine.AssertLogContains("WARNING MSB3644: " + message);
 }
コード例 #16
0
 public void TestGeneralFrameworkMonikerNonExistent()
 {
     MockEngine engine = new MockEngine();
     GetReferenceAssemblyPaths getReferencePaths = new GetReferenceAssemblyPaths();
     getReferencePaths.BuildEngine = engine;
     // Make a framework which does not exist, intentional mispelling of framework
     getReferencePaths.TargetFrameworkMoniker = ".NetFramewok, Version=v99.0";
     getReferencePaths.Execute();
     string[] returnedPaths = getReferencePaths.ReferenceAssemblyPaths;
     Assert.Equal(0, returnedPaths.Length);
     string displayName = getReferencePaths.TargetFrameworkMonikerDisplayName;
     Assert.Null(displayName);
     FrameworkNameVersioning frameworkMoniker = new FrameworkNameVersioning(getReferencePaths.TargetFrameworkMoniker);
     string message = ResourceUtilities.FormatResourceString("GetReferenceAssemblyPaths.NoReferenceAssemblyDirectoryFound", frameworkMoniker.ToString());
     engine.AssertLogContains(message);
 }
コード例 #17
0
        public void TestGeneralFrameworkMonikerGoodWithInvalidIncludePath()
        {
            string tempDirectory = Path.Combine(Path.GetTempPath(), "TestGeneralFrameworkMonikerGoodWithInvalidIncludePath");
            string framework41Directory = Path.Combine(tempDirectory, "MyFramework\\v4.1\\");
            string redistListDirectory = Path.Combine(framework41Directory, "RedistList");
            string redistListFile = Path.Combine(redistListDirectory, "FrameworkList.xml");
            try
            {
                Directory.CreateDirectory(framework41Directory);
                Directory.CreateDirectory(redistListDirectory);

                string redistListContents =
                        "<FileList Redist='Microsoft-Windows-CLRCoreComp' IncludeFramework='..\\Mooses' Name='Chained oh noes'>" +
                            "<File AssemblyName='System.Xml' Version='2.0.0.0' PublicKeyToken='b03f5f7f11d50a3a' Culture='Neutral' FileVersion='2.0.50727.208' InGAC='true' />" +
                             "<File AssemblyName='Microsoft.Build.Engine' Version='2.0.0.0' PublicKeyToken='b03f5f7f11d50a3a' Culture='Neutral' FileVersion='2.0.50727.208' InGAC='true' />" +
                        "</FileList >";

                File.WriteAllText(redistListFile, redistListContents);

                string targetFrameworkMoniker = "MyFramework, Version=v4.1";
                MockEngine engine = new MockEngine();
                GetReferenceAssemblyPaths getReferencePaths = new GetReferenceAssemblyPaths();
                getReferencePaths.BuildEngine = engine;
                getReferencePaths.TargetFrameworkMoniker = targetFrameworkMoniker;
                getReferencePaths.RootPath = tempDirectory;
                getReferencePaths.Execute();
                string[] returnedPaths = getReferencePaths.ReferenceAssemblyPaths;
                Assert.Equal(0, returnedPaths.Length);
                string displayName = getReferencePaths.TargetFrameworkMonikerDisplayName;
                Assert.Null(displayName);
                FrameworkNameVersioning frameworkMoniker = new FrameworkNameVersioning(getReferencePaths.TargetFrameworkMoniker);
                string message = ResourceUtilities.FormatResourceString("GetReferenceAssemblyPaths.NoReferenceAssemblyDirectoryFound", frameworkMoniker.ToString());
                engine.AssertLogContains(message);
            }
            finally
            {
                if (Directory.Exists(framework41Directory))
                {
                    Directory.Delete(framework41Directory, true);
                }
            }
        }
コード例 #18
0
        public void TestGeneralFrameworkMonikerNonExistent()
        {
            MockEngine engine = new MockEngine();
            GetReferenceAssemblyPaths getReferencePaths = new GetReferenceAssemblyPaths();

            getReferencePaths.BuildEngine = engine;
            // Make a framework which does not exist, intentional misspelling of framework
            getReferencePaths.TargetFrameworkMoniker = ".NetFramewok, Version=v99.0";
            bool success = getReferencePaths.Execute();

            Assert.False(success);
            string[] returnedPaths = getReferencePaths.ReferenceAssemblyPaths;
            Assert.Equal(0, returnedPaths.Length);
            string displayName = getReferencePaths.TargetFrameworkMonikerDisplayName;

            Assert.Null(displayName);
            FrameworkNameVersioning frameworkMoniker = new FrameworkNameVersioning(getReferencePaths.TargetFrameworkMoniker);
            string message = ResourceUtilities.FormatResourceString("GetReferenceAssemblyPaths.NoReferenceAssemblyDirectoryFound", frameworkMoniker.ToString());

            engine.AssertLogContains("ERROR MSB3644: " + message);
        }
コード例 #19
0
        /// <summary>
        /// Generate the set of chained reference assembly paths
        /// </summary>
        private IList <String> GetPaths(string rootPath, FrameworkNameVersioning frameworkmoniker)
        {
            IList <String> pathsToReturn = null;

            if (String.IsNullOrEmpty(rootPath))
            {
                pathsToReturn = ToolLocationHelper.GetPathToReferenceAssemblies(frameworkmoniker);
            }
            else
            {
                pathsToReturn = ToolLocationHelper.GetPathToReferenceAssemblies(rootPath, frameworkmoniker);
            }

            if (!SuppressNotFoundError)
            {
                // No reference assembly paths could be found, log an error so an invalid build will not be produced.
                // 1/26/16: Note this was changed from a warning to an error (see GitHub #173).
                if (pathsToReturn.Count == 0)
                {
                    Log.LogErrorWithCodeFromResources("GetReferenceAssemblyPaths.NoReferenceAssemblyDirectoryFound", frameworkmoniker.ToString());
                }
            }

            return(pathsToReturn);
        }
コード例 #20
0
        /// <summary>
        /// Generate the set of chained reference assembly paths
        /// </summary>
        private IList<String> GetPaths(string rootPath, FrameworkNameVersioning frameworkmoniker)
        {
            IList<String> pathsToReturn = null;

            if (String.IsNullOrEmpty(rootPath))
            {
                pathsToReturn = ToolLocationHelper.GetPathToReferenceAssemblies(frameworkmoniker);
            }
            else
            {
                pathsToReturn = ToolLocationHelper.GetPathToReferenceAssemblies(rootPath, frameworkmoniker);
            }

            // No reference assembly paths could be found, log an error so an invalid build will not be produced.
            // 1/26/16: Note this was changed from a warning to an error (see GitHub #173). Also added the escape hatch 
            // (set MSBUILDWARNONNOREFERENCEASSEMBLYDIRECTORY = 1) in case this causes issues.
            // TODO: This should be removed for Dev15
            if (pathsToReturn.Count == 0)
            {
                var warn = Environment.GetEnvironmentVariable(WARNONNOREFERENCEASSEMBLYDIRECTORY);

                if (string.Equals(warn, "1", StringComparison.Ordinal))
                {
                    Log.LogWarningWithCodeFromResources("GetReferenceAssemblyPaths.NoReferenceAssemblyDirectoryFound", frameworkmoniker.ToString());
                }
                else
                {
                    Log.LogErrorWithCodeFromResources("GetReferenceAssemblyPaths.NoReferenceAssemblyDirectoryFound", frameworkmoniker.ToString());
                }
            }

            return pathsToReturn;
        }