public override bool Execute()
        {
            var resolvedProjectContentFiles = ProjectContentFiles.Select(x => new { x.ItemSpec, FullPath = x.GetMetadata("FullPath") });
            var invalidProjectContentFiles  = resolvedProjectContentFiles.Where(x => string.IsNullOrEmpty(x.FullPath));

            if (invalidProjectContentFiles.Any())
            {
                throw new FrameworkException("Could not resolve the full path for the Rhetos input files " + string.Join(", ", invalidProjectContentFiles.Select(x => x.ItemSpec)).Limit(1000));
            }

            var assembliesInReferencedProjects        = Assemblies.Where(x => !string.IsNullOrEmpty(x.GetMetadata("Project"))).Select(x => new { x.ItemSpec, FullPath = x.GetMetadata("FullPath") });
            var invalidAssembliesInReferencedProjects = assembliesInReferencedProjects.Where(x => string.IsNullOrEmpty(x.FullPath));

            if (invalidAssembliesInReferencedProjects.Any())
            {
                throw new FrameworkException("Could not resolve the full path for the referenced assemblies " + string.Join(", ", invalidAssembliesInReferencedProjects.Select(x => x.ItemSpec)).Limit(1000));
            }

            var nuget = new NuGetUtilities(ProjectDirectory, resolvedProjectContentFiles.Select(x => x.FullPath), new NuGetLogger(Log), null);
            var packagesAssemblies = nuget.GetRuntimeAssembliesFromPackages();

            var rhetosBuildEnvironment = new RhetosBuildEnvironment
            {
                ProjectFolder         = Path.GetFullPath(ProjectDirectory),
                OutputAssemblyName    = AssemblyName,
                CacheFolder           = Path.GetFullPath(Path.Combine(ProjectDirectory, IntermediateOutputFolder)),
                GeneratedAssetsFolder = Path.GetFullPath(Path.Combine(ProjectDirectory, GeneratedAssetsFolder)),
                GeneratedSourceFolder = Path.GetFullPath(Path.Combine(ProjectDirectory, IntermediateOutputFolder, "RhetosSource")),
            };

            var rhetosTargetEnvironment = new RhetosTargetEnvironment
            {
                TargetPath         = Path.GetFullPath(Path.Combine(ProjectDirectory, TargetPath)),
                TargetAssetsFolder = Path.GetFullPath(Path.Combine(ProjectDirectory, TargetAssetsFolder)),
            };

            var rhetosProjectAssets = new RhetosProjectAssets
            {
                InstalledPackages = new InstalledPackages {
                    Packages = nuget.GetInstalledPackages()
                },
                Assemblies = packagesAssemblies.Union(assembliesInReferencedProjects.Select(x => x.FullPath)),
            };

            var rhetosProjectAssetsFileProvider = new RhetosProjectContentProvider(ProjectDirectory, new VSLogProvider(Log));

            rhetosProjectAssetsFileProvider.Save(rhetosBuildEnvironment, rhetosTargetEnvironment, rhetosProjectAssets);
            //The file touch is added to notify the language server that something has happened even if the file has not been changed.
            //This is a problem when in a referenced project we implement a new concept, the RhetosProjectAssetsFile remains the same but the language server
            //must be restarted to take into account the new concept
            FilesUtility.SafeTouch(rhetosProjectAssetsFileProvider.ProjectAssetsFilePath);

            return(true);
        }
Exemplo n.º 2
0
 public AppSettingsGenerator(
     RhetosBuildEnvironment rhetosBuildEnvironment,
     RhetosTargetEnvironment rhetosTargetEnvironment,
     LegacyPathsOptions legacyPathsOptions,
     ILogProvider logProvider,
     BuildOptions buildOptions)
 {
     _rhetosBuildEnvironment  = rhetosBuildEnvironment;
     _rhetosTargetEnvironment = rhetosTargetEnvironment;
     _legacyPathsOptions      = legacyPathsOptions;
     _logger       = logProvider.GetLogger(GetType().Name);
     _buildOptions = buildOptions;
 }