/// <summary> /// /// </summary> /// <param name="xmldatafile"></param> public bool ReadPerfResultsFromFile(string xmldatafile) { if (String.IsNullOrEmpty(xmldatafile)) { return(false); } FileStreamSW fs = new FileStreamSW(xmldatafile, System.IO.FileMode.Open); if (fs.Length == 0) { fs.Close(); return(false); } fs.Close(); XmlDocumentSW xmldoc = new XmlDocumentSW(); xmldoc.Load(xmldatafile); XmlNode subresultnode = xmldoc.CreateElement(Constants.PerfSubResultElement); XmlAttribute attrib = xmldoc.CreateAttribute("NAME"); string mainprojectfilename = null; for (int i = 0; i < xmldoc.DocumentElement.ChildNodes.Count; i++) { if (xmldoc.DocumentElement.ChildNodes[i].Name == PerfDatumElement) { subresultnode.InnerXml += xmldoc.DocumentElement.ChildNodes[i].OuterXml; } if (xmldoc.DocumentElement.ChildNodes[i].NodeType == XmlNodeType.Comment) { mainprojectfilename = xmldoc.DocumentElement.ChildNodes[i].Value; attrib.Value = "(" + ReportNode + ")"; } } subresultnode.Attributes.Append(attrib); PerfSubResult psr = new PerfSubResult(); psr.ReadSubResult(subresultnode); subresults = new Hashtable(); subresults.Add(mainprojectfilename + psr.SubResultName, psr); XmlNodeList subresultslist = xmldoc.DocumentElement.GetElementsByTagName(Constants.PerfSubResultElement); if (subresultslist.Count == 0) { return(false); } List <string> projectslist = new List <string>(); for (int i = 0; i < subresultslist.Count; i++) { psr = new PerfSubResult(); if (psr.ReadSubResult(subresultslist[i])) { subresults.Add(psr.SubResultName, psr); if (projectslist.Contains(psr.ProjectFileName) == false) { projectslist.Add(psr.ProjectFileName); } } psr = null; } perfresultslist = new Hashtable(projectslist.Count); for (int i = 0; i < projectslist.Count; i++) { PerfResult pr = new PerfResult(); pr.projectname = projectslist[i]; if (projectslist[i] == mainprojectfilename) { bmainprojectfile = true; } IDictionaryEnumerator ide = subresults.GetEnumerator(); while (ide.MoveNext()) { if (ide.Key.ToString().StartsWith(pr.projectname)) { if (pr.subresults == null) { pr.subresults = new Hashtable(); } pr.subresults.Add(ide.Key, ide.Value); } } perfresultslist.Add(pr.projectname, pr); } return(true); }
private List <ErrorWarningCode> CompileInternal(bool saveProjFile) { if (FileSW.Exists("ClickOnceTest.pfx")) { MSBuildProjExecutor.CleanSignFile = false; } MSBuildProjExecutor build = new MSBuildProjExecutor(); build.CreateProject(); build.CreateBuildPropertyGroup(""); build.CreateBuildItemGroup(""); build.AddProperty("Configuration", SetupParams.Configuration); build.AddProperty("Platform", "AnyCPU"); build.AddProperty("XamlDebuggingInformation", Convert.ToString(SetupParams.XamlDebuggingInformation)); build.AddProperty("OutputType", SetupParams.OutputType); if (!IsLibrary() && SetupParams.GenerateManifests) { build.AddProperty("GenerateManifests", Convert.ToString(SetupParams.GenerateManifests)); } string hostInBrowser = "false"; if (SetupParams.HostInBrowser) { hostInBrowser = "true"; } build.AddProperty("HostinBrowser", hostInBrowser); string localPath = SetupParams.LocalPath; if (String.IsNullOrEmpty(localPath)) { localPath = DirectorySW.GetCurrentDirectory(); } if (!IsLibrary() && SetupParams.TargetZone == "") { // This is for Full Trust Compilation string appManifest = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" + "<asmv1:assembly manifestVersion=\"1.0\" xmlns=\"urn:schemas-microsoft-com:asm.v1\" xmlns:asmv1=\"urn:schemas-microsoft-com:asm.v1\" xmlns:asmv2=\"urn:schemas-microsoft-com:asm.v2\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">" + " <trustInfo xmlns=\"urn:schemas-microsoft-com:asm.v2\">" + " <security>" + " <applicationRequestMinimum>" + " <PermissionSet class=\"System.Security.PermissionSet\" version=\"1\" Unrestricted=\"true\" ID=\"Custom\" SameSite=\"site\" />" + " <defaultAssemblyRequest permissionSetReference=\"Custom\" />" + " </applicationRequestMinimum>" + " </security>" + " </trustInfo>" + "</asmv1:assembly>"; string securityManifestFullTrust = "<Security>" + " <ApplicationRequestMinimum>" + " <PermissionSet ID=\"FT\" temp:Unrestricted=\"true\" />" + " <DefaultAssemblyRequest PermissionSetReference=\"FT\" />" + " </ApplicationRequestMinimum>" + "</Security>"; FileStreamSW fs = null; StreamWriterSW writer = null; if (!FileSW.Exists(app_manifest)) { try { string path = PathSW.Combine(localPath, app_manifest); fs = new FileStreamSW(path, FileMode.Create, FileAccess.Write); writer = new StreamWriterSW((Stream)fs.InnerObject); writer.Write(appManifest); } finally { if (writer != null) { writer.Close(); } if (fs != null) { fs.Close(); } } } if (!FileSW.Exists(SecurityManifestFullTrust)) { try { string path = PathSW.Combine(localPath, SecurityManifestFullTrust); fs = new FileStreamSW(path, FileMode.Create, FileAccess.Write); writer = new StreamWriterSW((Stream)fs.InnerObject); writer.Write(securityManifestFullTrust); } finally { if (writer != null) { writer.Close(); } if (fs != null) { fs.Close(); } } } build.AddProperty("TargetZone", "Custom"); build.AddItem("None", app_manifest); build.AddItem("None", SecurityManifestFullTrust); } build.AddProperty("AssemblyName", SetupParams.AssemblyName); build.AddProperty("OutputPath", SetupParams.OutputPath); build.AddProperty("RootNamespace", SetupParams.RootNamespace); build.AddProperty("UICulture", SetupParams.UICulture); if (!IsLibrary()) { build.AddItem("None", "ClickOnceTest.pfx"); build.AddProperty("SignManifests", "true"); build.AddProperty("ManifestKeyFile", "ClickOnceTest.pfx"); build.AddProperty("ManifestCertificateThumbprint", "cd582af19e477ae94a53102e0453e71b3c592a80"); } if (SetupParams.Language == Languages.CSharp) { build.AddImport(MSBuildDirectory + @"\Microsoft.CSharp.targets"); } else { build.AddImport(MSBuildDirectory + @"\Microsoft.VisualBasic.targets"); } build.AddImport(MSBuildDirectory + @"\Microsoft.WinFx.targets"); if (!String.IsNullOrEmpty(SetupParams.ApplicationDefinition)) { build.AddItem("ApplicationDefinition", SetupParams.ApplicationDefinition); } for (int i = 0; i < SetupParams.XamlPages.Count; i++) { build.AddItem("Page", SetupParams.XamlPages[i]); } for (int i = 0; i < SetupParams.CompileFiles.Count; i++) { build.AddItem("Compile", SetupParams.CompileFiles[i]); } for (int i = 0; i < SetupParams.Resources.Count; i++) { build.AddResource(SetupParams.Resources[i].FileName, SetupParams.Resources[i].FileStorage, ""); } for (int i = 0; i < SetupParams.Contents.Count; i++) { build.AddContent(SetupParams.Contents[i].FileName, SetupParams.Contents[i].CopyToOutputDirectory, ""); } for (int i = 0; i < SetupParams.References.Count; i++) { build.AddReference(SetupParams.References[i].FileName, "", SetupParams.References[i].HintPath, ""); } //HACK build.CommandLineArguements = "/t:Build"; if (saveProjFile) { build.SaveProjectFile = Path.Combine(localPath, "__CompilerServicesSave.proj"); } build.Build(); if (saveProjFile) { build.SaveProjectFile = Path.Combine(localPath, "__CompilerServicesSave.proj"); } if (build.OutputDirectory != null && !IsLibrary()) { string compiledExtension; if (SetupParams.HostInBrowser) { compiledExtension = ApplicationDeploymentHelper.BROWSER_APPLICATION_EXTENSION; } else { compiledExtension = ApplicationDeploymentHelper.STANDALONE_APPLICATION_EXTENSION; } if (SetupParams.GenerateManifests) { string fileToSign = PathSW.Combine(build.OutputDirectory, SetupParams.AssemblyName + compiledExtension); #if (!STRESS_RUNTIME) Microsoft.Test.Logging.GlobalLog.LogStatus("Signing file: " + fileToSign); #endif //MQ AvalonDeploymentHelper.SignManifest(fileToSign); } } return(build.UnhandledErrorsandWarningsList); }
public static FileStream Untrust(FileStreamSW stream) { return(stream.InnerObject); }