public override bool Execute()
        {
            try
            {
                var files = Directory.GetFiles(OutputPath, "*.*");

                foreach (var file in files)
                {
                    try
                    {
                        Log.LogCommandLine(MessageImportance.Normal, string.Format("Clean: \"{0}\"", file));
                        File.Delete(file);
                    }
                    catch (Exception ex)
                    {
                        throw new Exception(string.Format("Failed to delete \"{0}\": {1}", file, ex.Message));
                    }
                }
            }
            catch (Exception e)
            {
                var error = new BuildErrorEventArgs(null, null, "", 0, 0, 0, 0, e.Message, null, "Clean", DateTime.UtcNow);
                BuildEngine.LogErrorEvent(error);
                return(false);
            }

            return(true);
        }
Esempio n. 2
0
    public virtual void Flush()
    {
        var message = stringBuilder.ToString();

        message = message.Substring(0, message.Length - 2);
        BuildEngine.LogMessageEvent(new BuildMessageEventArgs(message, "", "Costura", MessageImportance));
    }
Esempio n. 3
0
 protected void LogMessage(string message, MessageImportance importance = MessageImportance.High)
 {
     if (BuildEngine != null)
     {
         BuildEngine.LogMessageEvent(new BuildMessageEventArgs("DnnPackager: " + message, "DnnPackager", "DnnPackager", importance));
     }
 }
Esempio n. 4
0
 protected void LogError(string code, string message)
 {
     if (BuildEngine != null)
     {
         BuildEngine.LogErrorEvent(new BuildErrorEventArgs("DnnPackager", code, null, 0, 0, 0, 0, message, "DnnPackager", "DnnPackager"));
     }
 }
Esempio n. 5
0
 private void LogMessage(string message, MessageImportance importance)
 {
     if (BuildEngine != null)
     {
         BuildEngine.LogMessageEvent(new BuildMessageEventArgs(message, null, null, importance));
     }
 }
Esempio n. 6
0
 private void LogWarning(string message, string code, string file, int lineNumber, int columnNumber)
 {
     if (BuildEngine != null)
     {
         BuildEngine.LogWarningEvent(new BuildWarningEventArgs("BinarySerialization", code, file, lineNumber, columnNumber, lineNumber, columnNumber, message, null, null));
     }
 }
Esempio n. 7
0
        public override bool Execute()
        {
            BuildEngine.LogMessageEvent(new BuildMessageEventArgs("ILRepackTask Executing (Change MessageImportance to get more or less info)", "", "ILRepackTask", Microsoft.Build.Framework.MessageImportance.High));

            var stopwatch = Stopwatch.StartNew();

            try
            {
                logger = new Logger
                {
                    SenderName  = "ILRepackTask",
                    BuildEngine = BuildEngine,
                };
                logger.Initialise(MessageImportance);
                Inner();
            }
            catch (Exception exception)
            {
                HandleException(exception);
            }

            finally
            {
                stopwatch.Stop();
                logger.Flush();
                BuildEngine.LogMessageEvent(new BuildMessageEventArgs(string.Format("\tFinished ({0}ms)", stopwatch.ElapsedMilliseconds), "", "ILRepackTask", Microsoft.Build.Framework.MessageImportance.High));
            }
            return(!logger.ErrorHasBeenRaised);
        }
Esempio n. 8
0
        public void MessagesByImportance(string value)
        {
            const string expectedMessage = "D2C36BFAE11847CE95B4135775E0156F";

            MessageImportance importance = (MessageImportance)Enum.Parse(typeof(MessageImportance), value);

            BuildEngine buildEngine = GetBuildEngineWithEvents(i => i.LogMessageEvent(new BuildMessageEventArgs(expectedMessage, null, null, importance)));

            string actualItem = buildEngine.Messages.ShouldHaveSingleItem();

            actualItem.ShouldBe(expectedMessage);

            switch (importance)
            {
            case MessageImportance.High:
                buildEngine.Messages.High.ShouldHaveSingleItem().ShouldBe(actualItem);
                break;

            case MessageImportance.Normal:
                buildEngine.Messages.Normal.ShouldHaveSingleItem().ShouldBe(actualItem);
                break;

            case MessageImportance.Low:
                buildEngine.Messages.Low.ShouldHaveSingleItem().ShouldBe(actualItem);
                break;
            }
        }
        private void CreateDotNetFrameworkVisualizer()
        {
            //if dot net visualizer exists already don't create it again
            if (FS.FileSystem.File.Exists(Path.Combine(VisualizerDestinationFolder, DotNetVisualizerAssemblyName)))
            {
                return;
            }
            try
            {
                //this is where the current assembly being built is saved
                string targetFolder = Path.GetDirectoryName(Assembly);

                //this is the place where the mapped dot net visualizer will be saved and then read
                string sourceDotNetAssemblyVisualizerFilePath = Path.Combine(targetFolder, DotNetVisualizerAssemblyName);

                //this is the target location for the dot net visualizer
                string targetDotNetAssemblyVisualizerFilePath = Path.Combine(VisualizerDestinationFolder, DotNetVisualizerAssemblyName);

                //map dot net framework types only if the assembly does not exist
                //it create such maps in the building folder
                MapDotNetFrameworkTypes(targetDotNetAssemblyVisualizerFilePath);

                //delete the temporary visualizer to avoid it dangling in the output folder (Debug/Release)
                FS.FileSystem.File.Delete(sourceDotNetAssemblyVisualizerFilePath);
                FS.FileSystem.File.Delete(Path.ChangeExtension(sourceDotNetAssemblyVisualizerFilePath, "pdb"));
            }
            catch (Exception exception)
            {
                const string errorMessage = "Error Mapping .Net Framework types";
                Log.Write(exception, errorMessage);
                BuildWarningEventArgs errorEvent = new BuildWarningEventArgs("Debugger Visualizer Creator", "", "MapperBuildTask", 0, 0, 0, 0, $"There was an error creating custom debugger visualizers for .Net Framework Types.", "", "LINQBridgeVs");
                BuildEngine.LogWarningEvent(errorEvent);
                exception.Capture(VisualStudioVer, message: errorMessage);
            }
        }
        private void CreateDebuggerVisualizer()
        {
            try
            {
                Log.Write("Visualizer Assembly location {0}", _dynamicVisualizerDllAssemblyPath);

                VisualizerAttributeInjector attributeInjector = new VisualizerAttributeInjector(_dynamicVisualizerDllAssemblyPath, VisualStudioVer);

                attributeInjector.MapTypesFromAssembly(Assembly);

                string targetInstallationFilePath = Path.Combine(VisualizerDestinationFolder, TargetVisualizerAssemblyName);

                attributeInjector.SaveDebuggerVisualizer(targetInstallationFilePath);

                Log.Write("Assembly {0} Mapped", Assembly);
            }
            catch (Exception e)
            {
                BuildErrorEventArgs errorEvent = new BuildErrorEventArgs("Debugger Visualizer Creator", "", "MapperBuildTask", 0, 0, 0, 0, $"There was an error creating custom debugger visualizers for project {Assembly}", "", "LINQBridgeVs");
                BuildEngine.LogErrorEvent(errorEvent);
                const string errorMessage = "Error creating debugger visualizers";
                Log.Write(e, errorMessage);

                e.Capture(VisualStudioVer, message: errorMessage);
            }
        }
Esempio n. 11
0
        public bool Execute()
        {
            Log.VisualStudioVersion = VisualStudioVer;

            try
            {
                string visualizerAssemblyName = VisualizerAssemblyNameFormat.GetTargetVisualizerAssemblyName(VisualStudioVer, Assembly);
                string targetInstallationPath = VisualStudioOption.GetVisualizerDestinationFolder(VisualStudioVer);

                string visualizerFullPath = Path.Combine(targetInstallationPath, visualizerAssemblyName);

                if (FS.FileSystem.File.Exists(visualizerFullPath))
                {
                    FS.FileSystem.File.Delete(visualizerFullPath);
                }

                //check if pdb also exists and delete it
                string visualizerPdbFullPath = Path.ChangeExtension(visualizerFullPath, "pdb");

                if (FS.FileSystem.File.Exists(visualizerPdbFullPath))
                {
                    FS.FileSystem.File.Delete(visualizerPdbFullPath);
                }
            }
            catch (System.Exception exception)
            {
                Log.Write(exception, "Error During cleanup");
                BuildWarningEventArgs errorEvent = new BuildWarningEventArgs("Debugger Visualizer Cleanup", "", "CleanBuildTask", 0, 0, 0, 0, $"There was an error cleaning custom debugger visualizers", "", "LINQBridgeVs");
                BuildEngine.LogWarningEvent(errorEvent);
                exception.Capture(VisualStudioVer, message: "Error during project cleaning");
            }

            return(true);
        }
Esempio n. 12
0
 void engine_ProjectPostBuild(BuildEngine engine, ProjectPostBuildEventArgs args)
 {
     if (args.BuildFailed)
     {
         args.Cancel = true;
     }
 }
Esempio n. 13
0
        protected void WaitForCompletion()
        {
            WaitHandle[] handles = new WaitHandle[] {
                logDataAvailable,
                errorDataAvailable,
                warningDataAvailable,
                customDataAvailable,
                taskCancelled,
                completed,
            };
            try {
                while (isRunning)
                {
                    var index = (WaitHandleIndex)System.Threading.WaitHandle.WaitAny(handles, TimeSpan.FromMilliseconds(10));
                    switch (index)
                    {
                    case WaitHandleIndex.LogDataAvailable:
                        LogInternal <BuildMessageEventArgs> (logMessageQueue, (e) => {
                                                        #pragma warning disable 618
                            Log.LogMessage(e.Importance, e.Message);
                                                        #pragma warning restore 618
                        }, logDataAvailable);
                        break;

                    case WaitHandleIndex.ErrorDataAvailable:
                        LogInternal <BuildErrorEventArgs> (errorMessageQueue, (e) => {
                                                        #pragma warning disable 618
                            Log.LogCodedError(e.Code, file: e.File, lineNumber: e.LineNumber, message: e.Message);
                                                        #pragma warning restore 618
                        }, errorDataAvailable);
                        break;

                    case WaitHandleIndex.WarningDataAvailable:
                        LogInternal <BuildWarningEventArgs> (warningMessageQueue, (e) => {
                                                        #pragma warning disable 618
                            Log.LogCodedWarning(e.Code, file: e.File, lineNumber: e.LineNumber, message: e.Message);
                                                        #pragma warning restore 618
                        }, warningDataAvailable);
                        break;

                    case WaitHandleIndex.CustomDataAvailable:
                        LogInternal <CustomBuildEventArgs> (customMessageQueue, (e) => {
                            BuildEngine.LogCustomEvent(e);
                        }, customDataAvailable);
                        break;

                    case WaitHandleIndex.TaskCancelled:
                        tcs.Cancel();
                        isRunning = false;
                        break;

                    case WaitHandleIndex.Completed:
                        isRunning = false;
                        break;
                    }
                }
            }
            finally {
            }
        }
Esempio n. 14
0
        public void LogErrorFromResources(string subcategoryResourceName,
                                          string errorCode,
                                          string helpKeyword,
                                          string file, int lineNumber,
                                          int columnNumber,
                                          int endLineNumber,
                                          int endColumnNumber,
                                          string messageResourceName,
                                          params object[] messageArgs)
        {
            if (messageResourceName == null)
            {
                throw new ArgumentNullException("messageResourceName");
            }

            ThrowInvalidOperationIf(BuildEngine == null, "Task is attempting to log before it was initialized");

            string subcategory = null;

            if (!String.IsNullOrEmpty(subcategoryResourceName))
            {
                subcategory = taskResources.GetString(subcategoryResourceName);
            }

            BuildErrorEventArgs beea = new BuildErrorEventArgs(
                subcategory,
                errorCode, file, lineNumber, columnNumber,
                endLineNumber, endColumnNumber,
                FormatResourceString(messageResourceName, messageArgs),
                helpKeyword, null);

            BuildEngine.LogErrorEvent(beea);
            hasLoggedErrors = true;
        }
        public bool Execute()
        {
            if (!File.Exists(ProjectFile))
            {
                BuildEngine.LogMessageEvent(new BuildMessageEventArgs(
                                                $"Failed to find project file \"{ProjectFile}\"",
                                                string.Empty,
                                                "GetProjectVersions",
                                                MessageImportance.High
                                                ));
                return(false);
            }

            try
            {
                UpdateValuesFromFile(ProjectFile);
                return(true);
            }
            catch (Exception e)
            {
                BuildEngine.LogMessageEvent(new BuildMessageEventArgs(
                                                $"Failed to load versions from file \"{ProjectFile}\", {e.Message}",
                                                string.Empty,
                                                "GetProjectVersions",
                                                MessageImportance.High
                                                ));
            }

            return(false);
        }
Esempio n. 16
0
        protected override int Run(BuildEngine engine)
        {
            foreach (ProjectInfo item in engine.Projects)
            {
                if (!String.IsNullOrEmpty(item.Properties[MSProp.SolutionDir]))
                {
                    continue;
                }

                //To attempt to gracefully handle those those that use SolutionDir in build rules...
                string        solutiondir = Path.GetDirectoryName(item.ProjectFile);
                DirectoryInfo parent      = new DirectoryInfo(solutiondir);
                while (parent != null)
                {
                    if (parent.GetFiles("*.sln").Length > 0)
                    {
                        solutiondir = parent.FullName;
                        break;
                    }
                    parent = parent.Parent;
                }

                if (!solutiondir.EndsWith(@"\"))
                {
                    solutiondir += @"\";
                }
                item.Properties[MSProp.SolutionDir] = solutiondir;
            }
            return(0);
        }
        public void A_Reserved_Word_As_A_Property_In_The_Source_Should_Throw_An_Error_With_The_Correct_Error_Exposed()
        {
            var compressor = GetJavascriptCompressorFor("Issue9719");

            compressor.Execute();
            Assert.That(BuildEngine.ContainsError(compressor.BuildEngine, ("invalid property id")));
        }
Esempio n. 18
0
		public ProjectBuilder (BuildEngine buildEngine, Engine engine, string file)
		{
			this.file = file;
			this.engine = engine;
			this.buildEngine = buildEngine;
			consoleLogger = new MDConsoleLogger (LoggerVerbosity.Normal, LogWriteLine, null, null);
		}
Esempio n. 19
0
        public bool Execute()
        {
            Log.VisualStudioVersion = VisualStudioVer;

            if (!CommonRegistryConfigurations.IsSolutionEnabled(SolutionName, VisualStudioVer))
            {
                return(true);
            }

            try
            {
                string snkCertificate = File.Exists(Snk) ? Snk : null;
                using (SInjection sInjection = new SInjection(Assembly, snkCertificate))
                {
                    return(sInjection.Patch());
                }
            }
            catch (Exception e)
            {
                const string errorMessage = "Error Executing MSBuild Task SInjectionBuildTask";
                Log.Write(e, errorMessage);
                e.Capture(VisualStudioVer, message: errorMessage);
                BuildWarningEventArgs errorEvent = new BuildWarningEventArgs("Debugger Visualizer Creator", "", "SInjectionBuildTask", 0, 0, 0, 0, $"There was an error adding the serializable attributes to type of the project {Assembly}. Please change serialization method from Binary to Json or Xml in Tools->Options->BridgeVs->SerializationOption. ", "", "LINQBridgeVs");
                BuildEngine.LogWarningEvent(errorEvent);
            }
            return(true);
        }
Esempio n. 20
0
        public bool Execute()
        {
            var files = InputFiles
                        .Select(x => x.ItemSpec)
                        .Where(Generator.IsMetaSharpFile)
                        .ToImmutableArray();
            var buildConstants = new BuildConstants(
                intermediateOutputPath: IntermediateOutputPath,
                targetPath: OutDir,
                generatorMode: GeneratorMode.MsBuild
                );
            var code = RealEnvironmentGenerator.Generate(
                files,
                buildConstants,
                error => BuildEngine.LogErrorEvent(ToBuildError(error)),
                output => OutputFiles = output.Select(x => new TaskItem(x)).ToArray()
                );

            return(code == GeneratorResultCode.Success);

            //var type = compilation.GlobalNamespace.GetNamespaceMembers().ElementAt(0).GetNamespaceMembers().ElementAt(0).GetTypeMembers().Single();
            //var tree = type.Locations.Single().SourceTree;
            //if(tree == compilation.SyntaxTrees.Single()) {
            //}
            //var node = compilation.SyntaxTrees.Single().GetRoot().DescendantNodes().OfType<ClassDeclarationSyntax>().First();
            //var model = compilation.GetSemanticModel(compilation.SyntaxTrees.Single());
            //var symbol = model.GetDeclaredSymbol(node);
            //if(symbol == type) {
            //}
        }
        public void ProducesAssemblyWithOneWorkingExport()
        {
            using (var testEnv = new TestEnvironment())
            {
                var testCode = @"namespace Test {
                                    public class TestClassA {
                                        [NXPorts.Attributes.DllExport]
                                        public static string DoSomething()
                                        {
                                            return ""TestReturnValue"";
                                        }
                                    }
                                }";
                if (!testEnv.CreateTestDLL("test", new[] { testCode }))
                {
                    Assert.Fail("Test compile failed.");
                }

                using (var testExportAttributedAssembly = new ExportAttributedAssembly("./test.dll"))
                {
                    var writer = new AssemblyExportWriterTask();
                    writer.BuildEngine = BuildEngine.Create();
                    writer.Write(testExportAttributedAssembly, "./test.dll");
                }

                Assert.That.RunsWithoutError <DoSomethingDelegate>(
                    "./test.dll",
                    "DoSomething",
                    d => {
                    Assert.AreEqual("TestReturnValue", d());
                }
                    );
            }
        }
        public void ProducesAssemblyWithoutExportAttributes()
        {
            using (var testEnv = new TestEnvironment())
            {
                var testCode = @"namespace Test {
                                    public class TestClassA {
                                        [NXPorts.Attributes.DllExport]
                                        public static void DoSomething() { }
                                    }
                                }";
                if (!testEnv.CreateTestDLL("test", new[] { testCode }))
                {
                    Assert.Fail("Test compile failed.");
                }

                using (var testExportAttributedAssembly = new ExportAttributedAssembly("./test.dll"))
                {
                    var writer = new AssemblyExportWriterTask();
                    writer.BuildEngine = BuildEngine.Create();
                    writer.Write(testExportAttributedAssembly, "./test.dll");
                }

                using (var resultModule = ModuleDefMD.Load("./test.dll"))
                {
                    var methodsWithOffendingAttribute = from t in resultModule.Types
                                                        from m in t.Methods
                                                        from ca in m.CustomAttributes
                                                        where ca.TypeFullName == typeof(Attributes.DllExportAttribute).FullName
                                                        select m;

                    Assert.AreEqual(0, methodsWithOffendingAttribute.Count(), $"Assembly was left with one ore more {nameof(Attributes.DllExportAttribute)} occurences.");
                }
            }
        }
Esempio n. 23
0
        public void TraversalReferencesWork()
        {
            ProjectCreator projectB = ProjectCreator
                                      .Create(GetTempFileName())
                                      .Save();

            ProjectCreator projectA = ProjectCreator
                                      .Create(GetTempFileName())
                                      .ItemProjectReference(projectB)
                                      .Save();

            ProjectCreator dirsProj = ProjectCreator
                                      .Create(GetTempFileName())
                                      .Property("IsTraversal", "true")
                                      .ItemInclude("ProjectFile", projectA.FullPath)
                                      .Save();

            BuildEngine buildEngine = BuildEngine.Create();

            MSBuildProjectLoader loader = new MSBuildProjectLoader(null, MSBuildToolsVersion, buildEngine);

            ProjectCollection projectCollection = loader.LoadProjectsAndReferences(new[] { dirsProj.FullPath });

            projectCollection.LoadedProjects.Select(i => i.FullPath).ShouldBe(
                new[] { dirsProj.FullPath, projectA.FullPath, projectB.FullPath },
                ignoreOrder: true);
        }
Esempio n. 24
0
        public void InvalidProjectsLogGoodInfo()
        {
            ProjectCreator projectA = ProjectCreator
                                      .Create(GetTempFileName())
                                      .Import(@"$(Foo)\foo.props")
                                      .Save();

            ProjectCreator dirsProj = ProjectCreator
                                      .Create(GetTempFileName())
                                      .Property("IsTraversal", "true")
                                      .ItemInclude("ProjectFile", projectA.FullPath)
                                      .Save();

            BuildEngine buildEngine = BuildEngine.Create();

            MSBuildProjectLoader loader = new MSBuildProjectLoader(null, MSBuildToolsVersion, buildEngine);

            loader.LoadProjectsAndReferences(new[] { dirsProj.FullPath });

            BuildErrorEventArgs errorEventArgs = buildEngine.ErrorEvents.ShouldHaveSingleItem();

            errorEventArgs.Code.ShouldBe("MSB4019");
            errorEventArgs.ColumnNumber.ShouldBe(3);
            errorEventArgs.HelpKeyword.ShouldBe("MSBuild.ImportedProjectNotFound");
            errorEventArgs.LineNumber.ShouldBe(3);
            errorEventArgs.File.ShouldBe(projectA.FullPath);
        }
Esempio n. 25
0
        public bool Execute()
        {
            //Debugger.Launch();
            OutputPath = OutputPath ?? AssemblyFile;
            var outputPdb = GetPdbPath(OutputPath);
            var input     = AssemblyFile;
            var inputPdb  = GetPdbPath(input);

            // Make a copy and delete the original file to prevent MSBuild from thinking that everything is OK
            if (OriginalCopyPath != null)
            {
                File.Copy(AssemblyFile, OriginalCopyPath, true);
                input = OriginalCopyPath;
                File.Delete(AssemblyFile);

                if (File.Exists(inputPdb))
                {
                    var copyPdb = GetPdbPath(OriginalCopyPath);
                    File.Copy(inputPdb, copyPdb, true);
                    File.Delete(inputPdb);
                    inputPdb = copyPdb;
                }
            }

            var msg = $"CompileRobustXamlTask -> AssemblyFile:{AssemblyFile}, ProjectDirectory:{ProjectDirectory}, OutputPath:{OutputPath}";

            BuildEngine.LogMessage(msg, MessageImportance.High);

            var res = XamlCompiler.Compile(BuildEngine, input,
                                           File.ReadAllLines(ReferencesFilePath).Where(l => !string.IsNullOrWhiteSpace(l)).ToArray(),
                                           ProjectDirectory, OutputPath,
                                           (SignAssembly && !DelaySign) ? AssemblyOriginatorKeyFile : null);

            if (!res.success)
            {
                return(false);
            }
            if (!res.writtentofile)
            {
                File.Copy(input, OutputPath, true);
                if (File.Exists(inputPdb))
                {
                    File.Copy(inputPdb, outputPdb, true);
                }
            }

            if (!string.IsNullOrEmpty(UpdateBuildIndicator))
            {
                if (!File.Exists(UpdateBuildIndicator))
                {
                    File.Create(UpdateBuildIndicator).Dispose();
                }
                else
                {
                    File.SetLastWriteTime(UpdateBuildIndicator, DateTime.Now);
                }
            }

            return(true);
        }
Esempio n. 26
0
        /// <summary>
        /// Attempts to get the current <see cref="ProjectInstance"/> of the executing task via reflection.
        /// </summary>
        /// <returns>A <see cref="ProjectInstance"/> object if one could be determined, otherwise null..</returns>
        private ProjectInstance GetProjectInstance()
        {
            try
            {
                FieldInfo requestEntryFieldInfo = BuildEngine.GetType().GetField("_requestEntry", BindingFlags.Instance | BindingFlags.NonPublic);

                if (requestEntryFieldInfo != null && BuildRequestEntryTypeLazy.Value != null && BuildRequestConfigurationTypeLazy.Value != null)
                {
                    object requestEntry = requestEntryFieldInfo.GetValue(BuildEngine);

                    if (requestEntry != null && BuildRequestEntryRequestConfigurationPropertyInfo.Value != null)
                    {
                        object requestConfiguration = BuildRequestEntryRequestConfigurationPropertyInfo.Value.GetValue(requestEntry);

                        if (requestConfiguration != null && BuildRequestConfigurationProjectPropertyInfo.Value != null)
                        {
                            return(BuildRequestConfigurationProjectPropertyInfo.Value.GetValue(requestConfiguration) as ProjectInstance);
                        }
                    }
                }
            }
            catch
            {
                // Ignored because we never want this method to throw since its using reflection to access internal members that could go away with any future release of MSBuild
            }

            return(null);
        }
        protected override int Run(BuildEngine engine)
        {
            FrameworkVersions currentTools = engine.Framework;

            foreach (ProjectInfo item in engine.Projects)
            {
                FrameworkVersions myFramework = currentTools;

                string projFramework = item.Properties[MSProp.TargetFrameworkVersion];
                if (!String.IsNullOrEmpty(projFramework))
                {
                    myFramework = (FrameworkVersions)Enum.Parse(typeof(FrameworkVersions), projFramework.Replace(".", ""));
                }

                foreach (ReferenceInfo r in item.References)
                {
                    if (r.RequiresVersion != null)
                    {
                        if (r.RequiresVersion.Value > myFramework)
                        {
                            item.References.Remove(r);
                        }
                    }
                }
            }
            return(0);
        }
Esempio n. 28
0
        public bool Execute()
        {
            var projectDir = Path.GetDirectoryName(BuildEngine.ProjectFileOfTaskNode);

            for (int i = 0; i < InputFiles.Length; i++)
            {
                BuildEngine.LogMessageEvent(new BuildMessageEventArgs(string.Format("Generating kernel wrappers for {0}", Path.GetFileName(InputFiles[i].ItemSpec)), "Kernel", "OpenCL.Net", MessageImportance.High));

                foreach (var mi in InputFiles[i].MetadataNames)
                {
                    BuildEngine.LogMessageEvent(new BuildMessageEventArgs(string.Format("\tMetadata: {0}: {1}", mi.ToString(), InputFiles[i].GetMetadata(mi.ToString())), "Kernel", "OpenCL.Net", MessageImportance.High));
                }

                var link     = InputFiles[i].GetMetadata(MetadataLink);
                var isLink   = !string.IsNullOrEmpty(link);
                var identity = InputFiles[i].GetMetadata(MetadataIdentity);
                var copy     = InputFiles[i].GetMetadata(MetadataCopyToOutputDirectory);
                var copyToOutputDirectory = !string.IsNullOrEmpty(copy) || (copy == "PreserveNewest") || (copy == "Always");
                var fullPath = InputFiles[i].GetMetadata(MetadataFullPath);

                var embedSource = !copyToOutputDirectory;
                var outputPath  = isLink ? link : identity;
                File.WriteAllText(OutputFiles[i].ItemSpec,
                                  ProcessKernelFile(fullPath, File.ReadAllText(InputFiles[i].ItemSpec), embedSource, outputPath));

                if (copyToOutputDirectory)
                {
                    InputFiles[i].RemoveMetadata(MetadataCopyToOutputDirectory);
                    OutputFiles[i].RemoveMetadata(MetadataCopyToOutputDirectory);
                }
            }

            BuildEngine.LogMessageEvent(new BuildMessageEventArgs("Done.", "Kernel", "OpenCL.Net", MessageImportance.High));
            return(true);
        }
        public void ProducesAssemblyWithoutAnyReferenceToNXPortAttributes()
        {
            using (var testEnv = new TestEnvironment())
            {
                var testCode = @"namespace Test {
                                    public class TestClassA {
                                        [NXPorts.Attributes.DllExport]
                                        public static void DoSomething()
                                        {
                                        }
                                    }
                                }";
                if (!testEnv.CreateTestDLL("test", new[] { testCode }))
                {
                    Assert.Fail("Test compile failed.");
                }

                using (var testExportAttributedAssembly = new ExportAttributedAssembly("./test.dll"))
                {
                    var writer = new AssemblyExportWriterTask();
                    writer.BuildEngine = BuildEngine.Create();
                    writer.Write(testExportAttributedAssembly, "./testOut.dll");
                }

                using (var resultModule = ModuleDefMD.Load("./testOut.dll"))
                {
                    var simpleNameOfAttributeAssembly = typeof(NXPorts.Attributes.DllExportAttribute).Assembly.GetName().Name;
                    Assert.AreEqual(
                        null,
                        resultModule.GetAssemblyRef(simpleNameOfAttributeAssembly),
                        $"Assembly was left with a reference to assembly '{simpleNameOfAttributeAssembly}'."
                        );
                }
            }
        }
Esempio n. 30
0
 private void GenericMSBuildLog(string message, MessageImportance messageImportance)
 {
     if (BuildEngine != null)
     {
         BuildEngine.LogMessageEvent(new BuildMessageEventArgs(message, HELP_KEYWORD, "git", messageImportance));
     }
 }
Esempio n. 31
0
        private void LogError(CompilerError error)
        {
            switch (error.Severity)
            {
            case ErrorSeverity.Error:
                BuildEngine.LogErrorEvent(new BuildErrorEventArgs(
                                              string.Empty,
                                              $"{error.StatusCode}",
                                              error.File,
                                              error.Line,
                                              error.Column,
                                              0, 0,
                                              error.Message,
                                              string.Empty,
                                              nameof(CompileSassFiles)));
                break;

            case ErrorSeverity.Warning:
                BuildEngine.LogWarningEvent(new BuildWarningEventArgs(
                                                string.Empty,
                                                $"{error.StatusCode}",
                                                error.File,
                                                error.Line,
                                                error.Column,
                                                0, 0,
                                                error.Message,
                                                string.Empty,
                                                nameof(CompileSassFiles)));
                break;
            }
        }
Esempio n. 32
0
        //private static PluginResolver pluginManager;
        private static void BuildStepsRecursively(BuildEngine.Builder builder, ICollection<BuildStep> steps, int stepsPerLevel, int maxLevel, BuildStep curParent = null, int curLevel = 0)
        {
            if (curLevel == maxLevel)
                return;

            for (var i = 0; i < stepsPerLevel; ++i)
            {
                BuildStep step = builder.Root.Add(new DoNothingCommand());
                if (curParent != null)
                    BuildStep.LinkBuildSteps(curParent, step);
                BuildStepsRecursively(builder, steps, stepsPerLevel, maxLevel, step, curLevel + 1);
                steps.Add(step);
            }
        }
Esempio n. 33
0
        public string CommandLineArguments(string pathToBuildFile, BuildEngine buildEngine, IPackageTree packageTree, FrameworkVersion version)
        {
            buildFile = pathToBuildFile;

            return GenerateParameters(buildEngine.Parameters);
        }