GetOutputFileName() public method

Gets the absolute path to the output file generated by this project.
public GetOutputFileName ( MonoDevelop.Projects.ConfigurationSelector configuration ) : FilePath
configuration MonoDevelop.Projects.ConfigurationSelector /// Build configuration. ///
return FilePath
Ejemplo n.º 1
0
        /// <summary>
        /// Returns the file name to an assembly, regardless of what
        /// type the assembly is.
        /// </summary>
        string GetReferencedFileName(ConfigurationSelector configuration)
        {
            switch (ReferenceType)
            {
            case ReferenceType.Assembly:
                return(reference);

            case ReferenceType.Gac:
                string file = AssemblyContext.GetAssemblyLocation(Reference, package, ownerProject != null? ownerProject.TargetFramework : null);
                return(file == null ? reference : file);

            case ReferenceType.Project:
                if (ownerProject != null)
                {
                    if (ownerProject.ParentSolution != null)
                    {
                        Project p = ownerProject.ParentSolution.FindProjectByName(reference);
                        if (p != null)
                        {
                            return(p.GetOutputFileName(configuration));
                        }
                    }
                }
                return(null);

            default:
                Console.WriteLine("pp: " + Reference + " " + OwnerProject.FileName);
                throw new NotImplementedException("unknown reference type : " + ReferenceType);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Returns the file name to an assembly, regardless of what
        /// type the assembly is.
        /// </summary>
        string GetReferencedFileName(ConfigurationSelector configuration)
        {
            switch (ReferenceType)
            {
            case ReferenceType.Assembly:
                return(reference);

            case ReferenceType.Package:
                string file = AssemblyContext.GetAssemblyLocation(Reference, package, ownerProject != null? ownerProject.TargetFramework : null);
                return(file == null ? reference : file);

            case ReferenceType.Project:
                if (ownerProject != null)
                {
                    if (ownerProject.ParentSolution != null)
                    {
                        Project p = ownerProject.ParentSolution.FindProjectByName(reference);
                        if (p != null)
                        {
                            return(p.GetOutputFileName(configuration));
                        }
                    }
                }
                return(null);

            default:
                return(null);
            }
        }
		public override DeployFileCollection GetProjectDeployFiles (DeployContext ctx, Project project, ConfigurationSelector configuration)
		{
			DeployFileCollection deployFiles = new DeployFileCollection ();
			base.GetProjectDeployFiles (ctx, project, configuration);
			// Add the compiled output file
			
			string outputFile = project.GetOutputFileName (configuration);
			if (!string.IsNullOrEmpty (outputFile))
				deployFiles.Add (new DeployFile (project, outputFile, Path.GetFileName (outputFile), TargetDirectory.ProgramFiles));
			
			// Collect deployable files
			foreach (ProjectFile file in project.Files) {
				// skip CopyToOutputDirectory files when it's just a project build, because 
				// MonoDevelop.Project.Projects already copies these files using more subtle overwriting
				// semantics
				if (file.CopyToOutputDirectory != FileCopyMode.None)
					continue;
				    
				DeployProperties props = new DeployProperties (file);
				if (props.ShouldDeploy) {
					DeployFile dp = new DeployFile (file);
					deployFiles.Add (dp);
					
					if (string.Compare (Path.GetFileName (dp.SourcePath), "app.config", true)==0 && string.Compare (Path.GetFileName (dp.RelativeTargetPath), "app.config", true)==0) {
						string newName = Path.GetFileName (outputFile) + ".config";
						dp.RelativeTargetPath = Path.Combine (Path.GetDirectoryName (dp.RelativeTargetPath), newName);
					}
				}
			}
			
			foreach (FileCopySet.Item item in project.GetSupportFileList (configuration)) {
				 deployFiles.Add (new DeployFile (project, item.Src, item.Target, TargetDirectory.ProgramFiles));
			}
			
			DotNetProject netProject = project as DotNetProject;
			if (netProject != null) {
				DotNetProjectConfiguration conf = (DotNetProjectConfiguration) project.GetConfiguration (configuration);
				if (conf.DebugMode) {
					string mdbFile = netProject.TargetRuntime.GetAssemblyDebugInfoFile (conf.CompiledOutputName);
					deployFiles.Add (new DeployFile (project, mdbFile, Path.GetFileName (mdbFile), TargetDirectory.ProgramFiles));
				}
			}
			
			return deployFiles;
		}
Ejemplo n.º 4
0
        static void AssertOutputFiles(Project project, string configuration, string[] expectedFiles)
        {
            string directory = Path.GetDirectoryName(project.GetOutputFileName((SolutionConfigurationSelector)configuration));

            Assert.IsFalse(string.IsNullOrEmpty(directory), "Project '{0} has no output directory", project);
            List <string> files = new List <string> (Directory.GetFiles(directory, "*", SearchOption.AllDirectories));

            for (int i = 0; i < files.Count; i++)
            {
                files[i] = files[i].Substring(directory.Length + 1);
            }

            foreach (string expectedFile in expectedFiles)
            {
                Assert.IsTrue(files.Remove(expectedFile), "Did not find file '{0}' in '{1}'",
                              expectedFile, directory);
            }

            Assert.IsTrue(files.Count == 0, "There are unexpected files in the directory {0}: {1}", directory, Join(files));
        }
		public override DeployFileCollection GetProjectDeployFiles (DeployContext ctx, Project project, ConfigurationSelector configuration)
		{
			DeployFileCollection deployFiles = new DeployFileCollection ();
			base.GetProjectDeployFiles (ctx, project, configuration);
			
			// Add the compiled output files
			
			ProjectConfiguration pconf = (ProjectConfiguration) project.GetConfiguration (configuration);
			FilePath outDir = pconf.OutputDirectory;
			foreach (FilePath file in project.GetOutputFiles (configuration)) {
				deployFiles.Add (new DeployFile (project, file, file.ToRelative (outDir), TargetDirectory.ProgramFiles));
			}
			
			FilePath outputFile = project.GetOutputFileName (configuration);
			
			// Collect deployable files
			foreach (ProjectFile file in project.Files) {
				// skip CopyToOutputDirectory files when it's just a project build, because 
				// MonoDevelop.Project.Projects already copies these files using more subtle overwriting
				// semantics
				if (file.CopyToOutputDirectory != FileCopyMode.None)
					continue;
				    
				DeployProperties props = new DeployProperties (file);
				if (props.ShouldDeploy) {
					DeployFile dp = new DeployFile (file);
					deployFiles.Add (dp);
					
					if (string.Compare (Path.GetFileName (dp.SourcePath), "app.config", true)==0 && string.Compare (Path.GetFileName (dp.RelativeTargetPath), "app.config", true)==0) {
						string newName = Path.GetFileName (outputFile) + ".config";
						dp.RelativeTargetPath = Path.Combine (Path.GetDirectoryName (dp.RelativeTargetPath), newName);
					}
				}
			}
			
			foreach (FileCopySet.Item item in project.GetSupportFileList (configuration)) {
				 deployFiles.Add (new DeployFile (project, item.Src, item.Target, TargetDirectory.ProgramFiles));
			}
			
			return deployFiles;
		}
Ejemplo n.º 6
0
            internal async Task <ProjectInfo> LoadProject(
                MonoDevelop.Projects.Project p,
                CancellationToken token,
                MonoDevelop.Projects.Project oldProject,
                ProjectCacheInfo cacheInfo,
                string framework)
            {
                var projectId = projectMap.GetOrCreateId(p, oldProject, framework);

                var config = await GetDotNetProjectConfiguration(p, framework).ConfigureAwait(false);

                MonoDevelop.Projects.DotNetCompilerParameters cp = config?.CompilationParameters;
                FilePath fileName = IdeApp.IsInitialized ? p.GetOutputFileName(IdeApp.Workspace.ActiveConfiguration) : (FilePath)"";

                if (fileName.IsNullOrEmpty)
                {
                    fileName = new FilePath(p.Name + ".dll");
                }

                if (cacheInfo == null)
                {
                    cacheInfo = await LoadProjectCacheInfo(p, config, framework, token).ConfigureAwait(false);

                    if (token.IsCancellationRequested)
                    {
                        return(null);
                    }

                    if (config != null)
                    {
                        workspaceCache.Update(config, framework, p, projectMap, cacheInfo);
                    }
                }

                if (token.IsCancellationRequested)
                {
                    return(null);
                }

                var loader = workspace.Services.GetService <IAnalyzerService> ().GetLoader();

                ProjectData      projectData, oldProjectData;
                ProjectDocuments projectDocuments;

                try {
                    await workspace.LoadLock.WaitAsync().ConfigureAwait(false);

                    //when reloading e.g. after a save, preserve document IDs
                    projectData = projectMap.ReplaceData(projectId, cacheInfo.References, out oldProjectData);

                    projectDocuments = await CreateDocuments(projectData, p, token, cacheInfo, oldProjectData).ConfigureAwait(false);

                    if (projectDocuments == null)
                    {
                        // Restore old document data if cancellation happens here.
                        projectMap.ReplaceData(projectId, oldProjectData, out _);
                        return(null);
                    }
                } finally {
                    workspace.LoadLock.Release();
                }

                if (token.IsCancellationRequested)
                {
                    return(null);
                }

                IEnumerable <DocumentInfo> documents = projectDocuments.Documents;
                var virtualDocuments = workspace.GetVirtualDocuments(projectId);

                if (virtualDocuments.Any())
                {
                    documents = documents.Concat(virtualDocuments);
                }

                // TODO: Pass in the WorkspaceMetadataFileReferenceResolver
                var info = ProjectInfo.Create(
                    projectId,
                    GetVersionStamp(p),
                    GetProjectInfoName(p.Name, framework),
                    fileName.FileNameWithoutExtension,
                    (p as MonoDevelop.Projects.DotNetProject)?.RoslynLanguageName ?? LanguageNames.CSharp,
                    p.FileName,
                    fileName,
                    null,                     // outputRefPath
                    null,                     // defaultNamespace
                    cp?.CreateCompilationOptions(),
                    cp?.CreateParseOptions(config),
                    documents,
                    cacheInfo.ProjectReferences,
                    cacheInfo.References.Select(x => x.CurrentSnapshot),
                    analyzerReferences: cacheInfo.AnalyzerFiles.SelectAsArray(x => {
                    var analyzer = new MonoDevelopAnalyzer(x, hostDiagnosticUpdateSource.Value, projectId, workspace, loader, LanguageNames.CSharp);
                    analyzersToDispose.Add(analyzer);
                    return(analyzer.GetReference());
                }),
                    analyzerConfigDocuments: projectDocuments.EditorConfigDocuments,
                    additionalDocuments: projectDocuments.AdditionalDocuments,
                    isSubmission: false,
                    hostObjectType: null,
                    hasAllInformation: true
                    );

                info = workspace.WithDynamicDocuments(p, info);

                return(info);
            }
Ejemplo n.º 7
0
		static void AssertOutputFiles (Project project, string configuration, string[] expectedFiles)
		{
			string directory = Path.GetDirectoryName (project.GetOutputFileName ((SolutionConfigurationSelector)configuration));
			Assert.IsFalse (string.IsNullOrEmpty (directory), "Project '{0} has no output directory", project);
			List<string> files = new List<string> (Directory.GetFiles (directory, "*", SearchOption.AllDirectories));
			
			for (int i = 0; i < files.Count; i++)
				files[i] = files[i].Substring (directory.Length + 1);
			
			foreach (string expectedFile in expectedFiles)
				Assert.IsTrue (files.Remove (expectedFile), "Did not find file '{0}' in '{1}'",
				               expectedFile, directory);
			
			Assert.IsTrue (files.Count == 0, "There are unexpected files in the directory {0}: {1}", directory, Join (files));
		}
Ejemplo n.º 8
0
            internal async Task <ProjectInfo> LoadProject(MonoDevelop.Projects.Project p, CancellationToken token, MonoDevelop.Projects.Project oldProject, ProjectCacheInfo cacheInfo)
            {
                var projectId = projectMap.GetOrCreateId(p, oldProject);

                var config = GetDotNetProjectConfiguration(p);

                MonoDevelop.Projects.DotNetCompilerParameters cp = config?.CompilationParameters;
                FilePath fileName = IdeApp.IsInitialized ? p.GetOutputFileName(IdeApp.Workspace.ActiveConfiguration) : (FilePath)"";

                if (fileName.IsNullOrEmpty)
                {
                    fileName = new FilePath(p.Name + ".dll");
                }

                if (cacheInfo == null)
                {
                    cacheInfo = await LoadProjectCacheInfo(p, config, token).ConfigureAwait(false);

                    if (token.IsCancellationRequested)
                    {
                        return(null);
                    }

                    if (config != null)
                    {
                        workspaceCache.Update(config, p, projectMap, cacheInfo);
                    }
                }

                if (token.IsCancellationRequested)
                {
                    return(null);
                }

                var loader = workspace.Services.GetService <IAnalyzerService> ().GetLoader();

                ProjectData         projectData, oldProjectData;
                List <DocumentInfo> mainDocuments, additionalDocuments;

                try {
                    await workspace.LoadLock.WaitAsync().ConfigureAwait(false);

                    //when reloading e.g. after a save, preserve document IDs
                    oldProjectData = projectMap.RemoveData(projectId);
                    projectData    = projectMap.CreateData(projectId, cacheInfo.References);

                    var documents = await CreateDocuments(projectData, p, token, cacheInfo.SourceFiles, oldProjectData).ConfigureAwait(false);

                    if (documents == null)
                    {
                        return(null);
                    }

                    mainDocuments       = documents.Item1;
                    additionalDocuments = documents.Item2;
                } finally {
                    workspace.LoadLock.Release();
                }

                // TODO: Pass in the WorkspaceMetadataFileReferenceResolver
                var info = ProjectInfo.Create(
                    projectId,
                    GetVersionStamp(p),
                    p.Name,
                    fileName.FileNameWithoutExtension,
                    (p as MonoDevelop.Projects.DotNetProject)?.RoslynLanguageName ?? LanguageNames.CSharp,
                    p.FileName,
                    fileName,
                    cp?.CreateCompilationOptions(),
                    cp?.CreateParseOptions(config),
                    mainDocuments,
                    cacheInfo.ProjectReferences,
                    cacheInfo.References.Select(x => x.CurrentSnapshot),
                    analyzerReferences: cacheInfo.AnalyzerFiles.SelectAsArray(x => {
                    var analyzer = new MonoDevelopAnalyzer(x, hostDiagnosticUpdateSource.Value, projectId, workspace, loader, LanguageNames.CSharp);
                    analyzersToDispose.Add(analyzer);
                    return(analyzer.GetReference());
                }),
                    additionalDocuments: additionalDocuments
                    );

                return(info);
            }
		// Populates configSection.DeployFileVars with unique DeployFiles for a particular config
		void ProcessDeployFilesForConfig (DeployFileCollection deployFiles, Project project, ConfigSection configSection, AutotoolsContext ctx, DotNetProjectConfiguration config)
		{
			//@deployFiles can have duplicates
			Dictionary<string, DeployFile> uniqueDeployFiles = new Dictionary<string, DeployFile> ();
			foreach (DeployFile dfile in deployFiles) {
				if (dfile.SourcePath == project.GetOutputFileName (configSection.Selector))
					continue;

				// DeployFileCollection can have duplicates, ignore them
				string key = dfile.RelativeTargetPath;
				if (!dfile.ContainsPathReferences)
					key += dfile.SourcePath;
				if (uniqueDeployFiles.ContainsKey (key))
					continue;
				uniqueDeployFiles [key] = dfile;

				string targetDeployVar = GetDeployVar (deployFileVars, dfile.RelativeTargetPath);
				configSection.DeployFileVars [targetDeployVar] = dfile;
				DeployFileData data = new DeployFileData ();
				data.File = dfile;
				data.Configuration = config;
				allDeployVars [targetDeployVar] = data;
			}
		}