本文整理汇总了C#中Project.GetDirectory方法的典型用法代码示例。如果您正苦于以下问题:C# Project.GetDirectory方法的具体用法?C# Project.GetDirectory怎么用?C# Project.GetDirectory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Project
的用法示例。
在下文中一共展示了Project.GetDirectory方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetFileSystemManipulatorForEnvironment
// FYI: VS SDK API for source control detection and support is really, really horrible.
public static async Task<ISccBasicFileSystem> GetFileSystemManipulatorForEnvironment(Project project)
{
var dte = project.DTE;
//if (!project.IsSourceControlled() && !dte.Solution.IsSourceControlled())
//{
// return new NonSccBasicFileSystem();
//}
var detectedSccSystem = await DetectSccSystem(project);
ISccBasicFileSystem result;
switch (detectedSccSystem)
{
case "tfs":
result = new TfsExeWrapper(project.GetDirectory(), dte.GetLogger());
break;
case "git":
result = new GitExeWrapper(project.GetDirectory(), dte.GetLogger());
break;
case "hg": // not yet implemented
//result = null;
result = new NonSccBasicFileSystem();
break;
case "svn": // not yet implemented
//result = null;
result = new NonSccBasicFileSystem();
break;
case null:
result = new NonSccBasicFileSystem();
break;
default: // not implemented
//result = null;
result = new NonSccBasicFileSystem();
break;
}
return result;
}
示例2: DetectSccSystem
private static async Task<string> DetectSccSystem(Project project)
{
// Did I mention? VS SDK API for source control detection and support is really, really horrible.
var tfs = new TfsExeWrapper(project.GetDirectory(), VsEnvironment.Dte.GetLogger());
if (await tfs.ItemIsUnderSourceControl(project.FullName)) return "tfs";
return //await DetectSccSystem(project.GetDirectory())
//??
await DetectSccSystem(project.DTE.Solution.GetDirectory());
}
示例3: DetectSccSystem
private static async Task<string> DetectSccSystem(Project project)
{
// Did I mention? VS SDK API for source control detection and support is really, really horrible.
var tfs = new TfsExeWrapper(project.GetDirectory(), VsEnvironment.Dte.GetLogger());
var projectFilePath = project.FullName;
if (string.IsNullOrWhiteSpace(projectFilePath)) return null;
if (!projectFilePath.Contains("://") && File.Exists(projectFilePath))
{
try
{
if (await tfs.ItemIsUnderSourceControl(projectFilePath))
{
return "tfs";
}
}
catch
{
//var logger = VsEnvironment.Dte.GetLogger();
//logger.LogError(
System.Diagnostics.Debug.WriteLine(
"Something went wrong when checking to see if this file is under source control: "
+ projectFilePath, "Error");
var fileInfo = new FileInfo(projectFilePath);
var sb = new StringBuilder();
sb.AppendLine("Exists: " + fileInfo.Exists);
sb.AppendLine("IsReadOnly: " + fileInfo.IsReadOnly);
sb.AppendLine("Length: " + fileInfo.Length);
sb.AppendLine("Name: " + fileInfo.Name);
sb.AppendLine("Attributes: " + fileInfo.Attributes.ToString());
//logger.LogError("File details ...\r\n" + sb.ToString());
System.Diagnostics.Debug.WriteLine(sb.ToString());
//throw; //return "tfs"; // whatever
}
}
var sccdir = project.DTE.Solution.GetDirectory();
if (string.IsNullOrEmpty(sccdir)) sccdir = project.GetDirectory();
return await DetectSccSystem(sccdir);
}
示例4: DetermineCheckState
private static bool? DetermineCheckState(Package package, Project project, string config, string filename)
{
var packageReferenceFile = new PackageReferenceFile(project.GetDirectory() + "/coapp.packages.config");
foreach (var p in packageReferenceFile.GetPackageReferences().Where(p => p.CanonicalName.Name == package.CanonicalName.Name &&
p.CanonicalName.Flavor == package.CanonicalName.Flavor &&
p.CanonicalName.Architecture == package.CanonicalName.Architecture))
{
if (filename == null)
return true;
if (config == null && p.Libraries.Any(l => l.Name == filename))
return true;
if (p.Libraries.Any(l => l.ConfigurationName == config && l.Name == filename))
return true;
}
return false;
}
示例5: ConfigureProject
/// <summary>
/// Configures the project for publishing.
/// </summary>
/// <param name="project">The project to configure.</param>
/// <param name="settings">The settings.</param>
/// <returns>
/// true, if the configuration was modified; otherwise, false.
/// </returns>
private bool ConfigureProject(Project project, ProjectSettings settings)
{
if (settings != null)
{
var window = new ProjectSettingsWindow(project.Name, settings);
// show dialog and modify settings
bool? saveSettings = window.ShowDialog(Globals.GetMainWindowHandle());
if (saveSettings.Value)
{
settings.Save();
// file does NOT exist?
if (!settings.Exists())
{
// add to project
string projectDir = project.GetDirectory();
string filePath = settings.FilePath;
if (filePath.StartsWith(projectDir, StringComparison.OrdinalIgnoreCase))
{
ProjectItem item = project.ProjectItems.AddFromFile(filePath);
Logger.Log(" -> Settings file added to project '{0}'", project.Name);
}
}
return true;
}
}
return false;
}