Esempio n. 1
0
        public string Compile(string outputAssemblyName, string fileVersion = null)
        {
            ProjectInfo projectInfo = GetProjectInfo();

            TransformFiles();
            ExtractResources();

            string[] references = projectInfo.References
                                  .Select(reference => _resourcesDir.Files.FirstOrDefault(f => f.Contains(reference)) ?? reference)
                                  .ToArray();

            CompilerResults result = new AssemblyCompiler()
                                     .Reference(references)
                                     .Reference(SystemReflectionNamespace)
                                     .WithCode(GetSourceCode(fileVersion))
                                     .WithIcon(_resourcesDir.Files.First(r => r.EndsWith(IconExtension)))
                                     .WithName(outputAssemblyName)
                                     .WithEmbeddedResource(_transformedFiles.Cast <string>())
                                     .WithEmbeddedResource(_resourcesDir.Files)
                                     .DefineSymbol("SELF_EXTRACTOR_COMPILER")
                                     .As(Target.WinExe)
                                     .Compile();

            return(result.PathToAssembly);
        }
        public void ExecWaitWithCapture_NullNames_OutputCaptured()
        {
            RemoteExecutor.Invoke(() =>
            {
                using (var tfc = new TempFileCollection())
                {
                    string outputName = null, errorName = null;

                    Assert.Equal(0, Executor.ExecWaitWithCapture(s_cmd, tfc, ref outputName, ref errorName));

                    Assert.Equal(3, tfc.Count);

                    Assert.NotEmpty(outputName);
                    Assert.NotEmpty(errorName);

                    Assert.Contains(outputName, tfc.Cast <string>());
                    Assert.Contains(errorName, tfc.Cast <string>());

                    Assert.NotEmpty(File.ReadAllText(outputName));
                    Assert.Empty(File.ReadAllText(errorName));
                }
            }).Dispose();
        }