本文整理汇总了C#中Project.GetFullPath方法的典型用法代码示例。如果您正苦于以下问题:C# Project.GetFullPath方法的具体用法?C# Project.GetFullPath怎么用?C# Project.GetFullPath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Project
的用法示例。
在下文中一共展示了Project.GetFullPath方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetProjectTemplateRoot
public static string GetProjectTemplateRoot(Project project)
{
if (project == null)
{
throw new ArgumentNullException("project");
}
return Path.Combine(project.GetFullPath(), "CodeTemplates");
}
示例2: SaveProjectConfig
private void SaveProjectConfig(Project project, XmlScaffoldingConfig config)
{
var projectConfigItem = project.GetProjectItem(ConfigXmlFilename);
if (projectConfigItem != null)
SaveConfigToFile(projectConfigItem.GetFullPath(), config);
else {
var outputFilename = Path.Combine(project.GetFullPath(), ConfigXmlFilename);
SaveConfigToFile(outputFilename, config);
project.ProjectItems.AddFromFile(outputFilename);
}
}
示例3: GetProjectManager
public override IProjectManager GetProjectManager(Project project)
{
IProjectManager projectManager;
if (_projectManagers.TryGetValue(project, out projectManager))
{
return projectManager;
}
var projectSystem = new MockVsProjectSystem(project);
var localRepository = new PackageReferenceRepository(
new MockFileSystem(project.GetFullPath()),
project.Name,
LocalRepository);
projectManager = new ProjectManager(
this,
PathResolver,
projectSystem,
localRepository);
_projectManagers[project] = projectManager;
return projectManager;
}
示例4: MockVsProjectSystem
public MockVsProjectSystem(Project project)
: base(VersionUtility.DefaultTargetFramework, project.GetFullPath())
{
_project = project;
}
示例5: GetTemplateOutput
private static TemplateRenderingResult GetTemplateOutput(Project project, IFileSystem fileSystem, string template, string projectRelativeOutputPath, Hashtable model, bool force)
{
var templateFullPath = FindTemplateAssertExists(project, fileSystem, template);
var templateContent = fileSystem.ReadAllText(templateFullPath);
templateContent = PreprocessTemplateContent(templateContent);
// Create the T4 host and engine
using (var host = new DynamicTextTemplatingEngineHost { TemplateFile = templateFullPath }) {
var t4Engine = GetT4Engine();
// Make it possible to reference the same assemblies that your project references
// using <@ Assembly @> directives.
host.AddFindableAssembly(FindProjectAssemblyIfExists(project));
foreach (dynamic reference in ((dynamic)project.Object).References) {
if ((!string.IsNullOrEmpty(reference.Path)) && (!reference.AutoReferenced))
host.AddFindableAssembly(reference.Path);
}
string projectRelativeOutputPathWithExtension = null;
ProjectItem existingOutputProjectItem = null;
if (!string.IsNullOrEmpty(projectRelativeOutputPath)) {
// Respect the <#@ Output Extension="..." #> directive
projectRelativeOutputPathWithExtension = projectRelativeOutputPath + GetOutputExtension(host, t4Engine, templateContent);
// Resolve the output path and ensure it doesn't already exist (unless "Force" is set)
var outputDiskPath = Path.Combine(project.GetFullPath(), projectRelativeOutputPathWithExtension);
existingOutputProjectItem = project.GetProjectItem(projectRelativeOutputPathWithExtension);
if (existingOutputProjectItem != null)
outputDiskPath = existingOutputProjectItem.GetFullPath();
if ((!force) && fileSystem.FileExists(outputDiskPath)) {
return new TemplateRenderingResult(projectRelativeOutputPathWithExtension) { SkipBecauseFileExists = true };
}
}
// Convert the incoming Hashtable to a dynamic object with properties for each of the Hashtable entries
host.Model = DynamicViewModel.FromObject(model);
// Run the text transformation
var templateOutput = t4Engine.ProcessTemplate(templateContent, host);
return new TemplateRenderingResult(projectRelativeOutputPathWithExtension) {
Content = templateOutput,
Errors = host.Errors,
ExistingProjectItemToOverwrite = existingOutputProjectItem,
};
}
}
示例6: FindProjectAssemblyIfExists
private static string FindProjectAssemblyIfExists(Project project)
{
if ((project.ConfigurationManager != null)
&& (project.ConfigurationManager.ActiveConfiguration != null)
&& (project.ConfigurationManager.ActiveConfiguration.Properties != null)
&& (project.ConfigurationManager.ActiveConfiguration.Properties.Item("OutputPath") != null)
&& (!string.IsNullOrEmpty((string)project.ConfigurationManager.ActiveConfiguration.Properties.Item("OutputPath").Value))
&& (project.Properties.Item("OutputFileName") != null)
&& (!string.IsNullOrEmpty((string)project.Properties.Item("OutputFileName").Value))
) {
var outputDir = Path.Combine(project.GetFullPath(), (string)project.ConfigurationManager.ActiveConfiguration.Properties.Item("OutputPath").Value);
var assemblyLocation = Path.Combine(outputDir, (string)project.Properties.Item("OutputFileName").Value);
if (File.Exists(assemblyLocation))
return assemblyLocation;
}
return null;
}
示例7: AddTextFileToProject
private static void AddTextFileToProject(Project project, IFileSystem fileSystem, string projectRelativePath, string text)
{
// Need to be sure the folder exists first
var outputDirPath = Path.GetDirectoryName(projectRelativePath);
var projectDir = project.GetOrCreateProjectItems(outputDirPath, true /* create */, fileSystem);
var diskPath = Path.Combine(project.GetFullPath(), projectRelativePath);
fileSystem.WriteAllText(diskPath, text);
projectDir.AddFromFile(diskPath);
}
示例8: TranslatePath
/// <summary>
/// Splits a PATH (with ; or : as separators) into its parts, while
/// resolving references to environment variables.
/// </summary>
/// <param name="project">The <see cref="Project" /> to be used to resolve relative paths.</param>
/// <param name="source">The path to translate.</param>
/// <returns>
/// A PATH split up its parts, with references to environment variables
/// resolved and duplicate entries removed.
/// </returns>
public static StringCollection TranslatePath(Project project, string source)
{
StringCollection result = new StringCollection();
if (source == null) {
return result;
}
string[] parts = source.Split(':',';');
for (int i = 0; i < parts.Length; i++) {
string part = parts[i];
// on a DOS filesystem, the ':' character might be part of a
// drive spec and in that case we need to combine the current
// and the next part
if (part.Length == 1 && Char.IsLetter(part[0]) && _dosBasedFileSystem && (parts.Length > i + 1)) {
string nextPart = parts[i + 1].Trim();
if (nextPart.StartsWith("\\") || nextPart.StartsWith("/")) {
part += ":" + nextPart;
// skip the next part as we've also processed it
i++;
}
}
// expand env variables in part
string expandedPart = Environment.ExpandEnvironmentVariables(part);
// check if part is a reference to an environment variable
// that could not be expanded (does not exist)
if (expandedPart.StartsWith("%") && expandedPart.EndsWith("%")) {
continue;
}
// resolve each part in the expanded environment variable to a
// full path
foreach (string path in expandedPart.Split(Path.PathSeparator)) {
try {
string absolutePath = project.GetFullPath(path);
if (!result.Contains(absolutePath)) {
result.Add(absolutePath);
}
} catch (Exception ex) {
project.Log(Level.Verbose, "Dropping path element '{0}'"
+ " as it could not be resolved to a full path. {1}",
path, ex.Message);
}
}
}
return result;
}
示例9: ReadFromXml
/// <summary>
/// Populates the project from the xml definition file
/// </summary>
/// <param name="project"></param>
/// <param name="FilePath">The file to read the project definition from.</param>
public static void ReadFromXml(Project project, string FilePath)
{
project.ClearUserOptions();
project.Functions.Clear();
XPathDocument doc = null;
string ext = Path.GetExtension(FilePath);
if (ext == ".st")
{
doc = new XPathDocument(FilePath);
}
else if (ext == ".stz")
{
// Delete all files in the temp folder
if (Directory.Exists(Controller.TempPath))
{
Directory.Delete(Controller.TempPath, true);
}
Directory.CreateDirectory(Controller.TempPath);
Utility.UnzipFile(FilePath, Controller.TempPath);
string[] includedFiles = Directory.GetFiles(Controller.TempPath, "*");
project.ClearIncludedFiles();
foreach (string file in includedFiles)
{
if (!Utility.StringsAreEqual(Path.GetFileName(file), "definition.xml", false))
{
project.AddIncludedFile(new IncludedFile(Path.GetFileName(file)));
}
}
string xmlPath = Path.Combine(Controller.TempPath, "definition.xml");
// Backward compatability mpr
StreamReader reader = new StreamReader(xmlPath);
string definitionXml = reader.ReadToEnd();
reader.Close();
StreamWriter writer = File.CreateText(xmlPath);
//writer.Write(Convert.Script.Replace(definitionXml));
writer.Write(definitionXml);
writer.Close();
// mpr
doc = new XPathDocument(xmlPath);
}
XPathNavigator rootNavigator = doc.CreateNavigator();
XPathNavigator navigator = rootNavigator.SelectSingleNode(@"ROOT/config/project");
XPathNavigator fileVersionNavigator = rootNavigator.SelectSingleNode(@"ROOT/@fileversion");
int fileVersion = fileVersionNavigator != null ? fileVersionNavigator.ValueAsInt : 0;
List<string> missingTypesMessages = new List<string>();
#region Project details
project.ProjectName = navigator.SelectSingleNode("name").Value;
project.ProjectDescription = navigator.SelectSingleNode("description").Value;
ReadXmlReferencedFiles(project, FilePath, rootNavigator);
string compileFolderRelPath = navigator.SelectSingleNode("compilefile") == null ? "" : navigator.SelectSingleNode("compilefile").Value;
compileFolderRelPath = project.GetFullPath(compileFolderRelPath);
project.DebugProjectFile = navigator.SelectSingleNode("debugfile") == null ? "" : navigator.SelectSingleNode("debugfile").Value;
project.TestGenerateDirectory = navigator.SelectSingleNode("testgeneratedirectory") == null ? "" : navigator.SelectSingleNode("testgeneratedirectory").Value;
if (Directory.Exists(compileFolderRelPath))
{
compileFolderRelPath = Path.GetDirectoryName(compileFolderRelPath);
}
else
{
compileFolderRelPath = Path.GetDirectoryName(project.ProjectFileName);
}
project.CompileFolderName = compileFolderRelPath;
//CompileFolderName = GetFullPath(CompileFolderName);
project.Version = navigator.SelectSingleNode("version") == null ? "0.0.0" : navigator.SelectSingleNode("version").Value;
project.Namespaces.Clear();
project.Namespaces.AddRange(rootNavigator.SelectSingleNode(@"ROOT/namespaces").Value.Split(','))
;
#endregion
//#region Default Value Functions
//m_defaultValueFunctions = new List<DefaultValueFunction>();
//foreach (XPathNavigator subNode in navigator.Select("defaultvaluefunctions/defaultvaluefunction"))
//{
// ReadXmlDefaultValueFunctionNode(missingTypesMessages, subNode);
//}
//#endregion
#region Functions
foreach (XPathNavigator funcNode in rootNavigator.Select("/ROOT/function"))
{
ReadXmlFunctionNode(project, missingTypesMessages, funcNode);
}
project.SortFunctions();
#endregion
//.........这里部分代码省略.........
示例10: GetFullPathOfReferencedFile
/// <summary>
/// Gets the full path of a referenced file, by looking in all the obvious places. Returns
/// just the filename if the full path can't be determined.
/// </summary>
/// <param name="relativePath"></param>
/// <returns></returns>
private static string GetFullPathOfReferencedFile(Project project, string relativePath)
{
string refFilePath = project.GetFullPath(relativePath);
if (!File.Exists(refFilePath))
{
string refFileName = Path.GetFileName(refFilePath);
// Can we find the file in the same folder as the current project file (.stz)?
string pathToCheck = Path.Combine(Path.GetDirectoryName(project.ProjectFileName), refFileName);
if (File.Exists(pathToCheck))
{
refFilePath = pathToCheck;
}
else
{
// Can we find it in the application path?
pathToCheck = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), refFileName);
if (File.Exists(pathToCheck))
{
refFilePath = pathToCheck;
}
else
{
// We still can't find it anywhere, so let's rather make the path blank, rather
// than a weird non-existant one from the development environment!
refFilePath = refFileName;
}
}
}
return refFilePath;
}