public async Task NetStandard_EnsureGeneratedAssemblyInfoAvailableToTypeSystem()
        {
            var solFile = Util.GetSampleProject("netstandard-sdk", "netstandard-sdk.sln");

            using (var sol = (Solution)await Services.ProjectService.ReadWorkspaceItem(Util.GetMonitor(), solFile)) {
                var p = (Project)sol.Items [0];

                RestoreNuGetPackages(solFile);

                var debugConfig      = new SolutionConfigurationSelector("Debug");
                var debugSourceFiles = await p.GetSourceFilesAsync(Util.GetMonitor(), debugConfig);

                var releaseConfig      = new SolutionConfigurationSelector("Release");
                var releaseSourceFiles = await p.GetSourceFilesAsync(Util.GetMonitor(), releaseConfig);

                var expectedDebugAssemblyInfoFile   = p.BaseIntermediateOutputPath.Combine("Debug", "netstandard1.4", "netstandard-sdk.AssemblyInfo.cs");
                var expectedReleaseAssemblyInfoFile = p.BaseIntermediateOutputPath.Combine("Release", "netstandard1.4", "netstandard-sdk.AssemblyInfo.cs");

                Assert.IsTrue(debugSourceFiles.Any(f => f.FilePath == expectedDebugAssemblyInfoFile));
                Assert.IsTrue(releaseSourceFiles.Any(f => f.FilePath == expectedReleaseAssemblyInfoFile));
            }
        }
        public async Task NetStandard_EnsureGeneratedAssemblyInfoAvailableToTypeSystem()
        {
            var solFile = Util.GetSampleProject("netstandard-sdk", "netstandard-sdk.sln");

            using (var sol = (Solution)await Services.ProjectService.ReadWorkspaceItem(Util.GetMonitor(), solFile)) {
                var p = (Project)sol.Items [0];

                var process = Process.Start("msbuild", $"/t:Restore \"{solFile}\"");
                Assert.IsTrue(process.WaitForExit(120000), "Timeout restoring NuGet packages.");
                Assert.AreEqual(0, process.ExitCode);

                var debugConfig      = new SolutionConfigurationSelector("Debug");
                var debugSourceFiles = await p.GetSourceFilesAsync(Util.GetMonitor(), debugConfig);

                var releaseConfig      = new SolutionConfigurationSelector("Release");
                var releaseSourceFiles = await p.GetSourceFilesAsync(Util.GetMonitor(), releaseConfig);

                var expectedDebugAssemblyInfoFile   = p.BaseIntermediateOutputPath.Combine("Debug", "netstandard1.4", "netstandard-sdk.AssemblyInfo.cs");
                var expectedReleaseAssemblyInfoFile = p.BaseIntermediateOutputPath.Combine("Release", "netstandard1.4", "netstandard-sdk.AssemblyInfo.cs");

                Assert.IsTrue(debugSourceFiles.Any(f => f.FilePath == expectedDebugAssemblyInfoFile));
                Assert.IsTrue(releaseSourceFiles.Any(f => f.FilePath == expectedReleaseAssemblyInfoFile));
            }
        }
Example #3
0
        protected override bool OnBuild(IProgressMonitor monitor, DeployContext ctx)
        {
            string tmpFolder = null;

            try {
                SolutionConfigurationSelector conf = (SolutionConfigurationSelector)configuration;
                BuildResult res = RootSolutionItem.Build(monitor, conf);
                if (res.ErrorCount > 0)
                {
                    foreach (BuildError e in res.Errors)
                    {
                        monitor.ReportError(e.ToString(), null);
                    }
                    monitor.ReportError(GettextCatalog.GetString("The source project failed to build."), null);
                    return(false);
                }

                tmpFolder = FileService.CreateTempDirectory();

                string tf = Path.GetFileNameWithoutExtension(targetFile);
                if (tf.EndsWith(".tar"))
                {
                    tf = Path.GetFileNameWithoutExtension(tf);
                }
                string folder = FileService.GetFullPath(Path.Combine(tmpFolder, tf));

                // Export the binary files
                DeployFileCollection deployFiles = GetDeployFiles(ctx, conf);
                foreach (DeployFile file in deployFiles)
                {
                    string tfile = Path.Combine(folder, file.ResolvedTargetFile);
                    string tdir  = FileService.GetFullPath(Path.GetDirectoryName(tfile));
                    if (!Directory.Exists(tdir))
                    {
                        Directory.CreateDirectory(tdir);
                    }
                    File.Copy(file.SourcePath, tfile, true);
                }

                // Create the archive
                string td = Path.GetDirectoryName(targetFile);
                if (!Directory.Exists(td))
                {
                    Directory.CreateDirectory(td);
                }
                DeployService.CreateArchive(monitor, tmpFolder, targetFile);
            }
            catch (Exception ex) {
                monitor.ReportError("Package creation failed", ex);
                LoggingService.LogError("Package creation failed", ex);
                return(false);
            }
            finally {
                if (tmpFolder != null)
                {
                    Directory.Delete(tmpFolder, true);
                }
            }
            if (monitor.AsyncOperation.Success)
            {
                monitor.Log.WriteLine(GettextCatalog.GetString("Created file: {0}", targetFile));
            }
            return(true);
        }