本文整理汇总了C#中Microsoft.Build.Construction.ProjectRootElement.AddImport方法的典型用法代码示例。如果您正苦于以下问题:C# ProjectRootElement.AddImport方法的具体用法?C# ProjectRootElement.AddImport怎么用?C# ProjectRootElement.AddImport使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Build.Construction.ProjectRootElement
的用法示例。
在下文中一共展示了ProjectRootElement.AddImport方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Process
public override void Process(
ProjectRootElement project,
Dictionary<string, ProjectPropertyGroupElement> groups
) {
ProjectPropertyGroupElement imports;
if (!groups.TryGetValue("Imports", out imports)) {
imports = project.AddPropertyGroup();
}
AddOrSetProperty(imports, "PtvsTargetsFile", @"$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\Python Tools\Microsoft.PythonTools.targets");
project.AddImport("$(PtvsTargetsFile)").Condition = "Exists($(PtvsTargetsFile))";
project.AddImport(@"$(MSBuildToolsPath)\Microsoft.Common.targets").Condition = "!Exists($(PtvsTargetsFile))";
}
示例2: CreateBuildProject
void CreateBuildProject()
{
string projectPath = Path.Combine(buildDirectory, "content.contentproj");
string outputPath = Path.Combine(buildDirectory, "bin");
// Create the build project.
projectRootElement = ProjectRootElement.Create(projectPath);
// Include the standard targets file that defines how to build XNA Framework content.
projectRootElement.AddImport(Application.StartupPath + "\\Exporters\\FBX\\XNA\\XNA Game Studio\\" +
"v4.0\\Microsoft.Xna.GameStudio.ContentPipeline.targets");
buildProject = new Project(projectRootElement);
buildProject.SetProperty("XnaPlatform", "Windows");
buildProject.SetProperty("XnaProfile", "Reach");
buildProject.SetProperty("XnaFrameworkVersion", "v4.0");
buildProject.SetProperty("Configuration", "Release");
buildProject.SetProperty("OutputPath", outputPath);
buildProject.SetProperty("ContentRootDirectory", ".");
buildProject.SetProperty("ReferencePath", Application.StartupPath);
// Register any custom importers or processors.
foreach (string pipelineAssembly in pipelineAssemblies)
{
buildProject.AddItem("Reference", pipelineAssembly);
}
// Hook up our custom error logger.
errorLogger = new ErrorLogger();
buildParameters = new BuildParameters(ProjectCollection.GlobalProjectCollection)
{Loggers = new ILogger[] {errorLogger}};
}
示例3: AddImport
static ProjectImportElement AddImport(
ProjectRootElement projectRoot,
string importedProjectFile,
ProjectImportLocation importLocation)
{
if (importLocation == ProjectImportLocation.Top) {
return AddImportAtTop(projectRoot, importedProjectFile);
}
return projectRoot.AddImport(importedProjectFile);
}
示例4: CreateBuildProject
/// <summary>
/// Creates a temporary MSBuild content project in memory.
/// </summary>
private void CreateBuildProject()
{
string projectPath = Path.Combine(_buildDirectory, "content.contentproj");
string outputPath = Path.Combine(_buildDirectory, "bin");
// Create the build project.
_projectRootElement = ProjectRootElement.Create(projectPath);
// Include the standard targets file that defines how to build XNA Framework content.
_projectRootElement.AddImport("$(MSBuildExtensionsPath)\\Microsoft\\XNA Game Studio\\"
+ "v4.0\\Microsoft.Xna.GameStudio.ContentPipeline.targets");
_buildProject = new Project(_projectRootElement);
_buildProject.SetProperty("XnaPlatform", "Windows");
IOptionsService optionsService = (IOptionsService) _serviceProvider.GetService(typeof (IOptionsService));
_buildProject.SetProperty("XnaProfile", optionsService.GetContentPreviewOptions().Profile.ToString());
_buildProject.SetProperty("XnaFrameworkVersion", XnaConstants.XnaFrameworkVersion);
_buildProject.SetProperty("Configuration", "Release");
_buildProject.SetProperty("OutputPath", outputPath);
// Hook up our custom error logger.
_errorLogger = new ErrorLogger();
_buildParameters = new BuildParameters(ProjectCollection.GlobalProjectCollection);
_buildParameters.Loggers = new ILogger[] { _errorLogger };
}
示例5: UpgradeProject
protected override void UpgradeProject(
ref ProjectRootElement projectXml,
ref ProjectRootElement userProjectXml,
Action<__VSUL_ERRORLEVEL, string> log
) {
Version version;
// ToolsVersion less than 4.0 (or unspecified) is not supported, so
// set it to 4.0.
if (!Version.TryParse(projectXml.ToolsVersion, out version) ||
version < new Version(4, 0)) {
projectXml.ToolsVersion = "4.0";
log(__VSUL_ERRORLEVEL.VSUL_INFORMATIONAL, SR.GetString(SR.UpgradedToolsVersion));
}
// Importing a targets file from 2.1 Beta
var bottleImports = projectXml.Imports.Where(p => p.Project.Equals(Ptvs21BetaBottleTargets, StringComparison.OrdinalIgnoreCase)).ToList();
var flaskImports = projectXml.Imports.Where(p => p.Project.Equals(Ptvs21BetaFlaskTargets, StringComparison.OrdinalIgnoreCase)).ToList();
foreach (var import in bottleImports.Concat(flaskImports)) {
import.Project = WebTargets;
}
if (bottleImports.Any()) {
var globals = projectXml.PropertyGroups.FirstOrDefault() ?? projectXml.AddPropertyGroup();
AddOrSetProperty(globals, "PythonDebugWebServerCommandArguments", "--debug $(CommandLineArguments)");
AddOrSetProperty(globals, "PythonWsgiHandler", "{StartupModule}.wsgi_app()");
log(__VSUL_ERRORLEVEL.VSUL_INFORMATIONAL, SR.GetString(SR.UpgradedBottleImports));
}
if (flaskImports.Any()) {
var globals = projectXml.PropertyGroups.FirstOrDefault() ?? projectXml.AddPropertyGroup();
AddOrSetProperty(globals, "PythonWsgiHandler", "{StartupModule}.wsgi_app");
log(__VSUL_ERRORLEVEL.VSUL_INFORMATIONAL, SR.GetString(SR.UpgradedFlaskImports));
}
var commonPropsImports = projectXml.Imports.Where(p => p.Project.Equals(CommonProps, StringComparison.OrdinalIgnoreCase)).ToList();
foreach (var p in commonPropsImports) {
projectXml.RemoveChild(p);
log(__VSUL_ERRORLEVEL.VSUL_INFORMATIONAL, SR.GetString(SR.UpgradedRemoveCommonProps));
}
if (projectXml.Imports.Count == 1 && projectXml.Imports.First().Project.Equals(CommonTargets, StringComparison.OrdinalIgnoreCase)) {
projectXml.RemoveChild(projectXml.Imports.First());
var group = projectXml.AddPropertyGroup();
if (!projectXml.Properties.Any(p => p.Name == "VisualStudioVersion")) {
group.AddProperty("VisualStudioVersion", "10.0").Condition = "'$(VisualStudioVersion)' == ''";
}
group.AddProperty("PtvsTargetsFile", PtvsTargets);
projectXml.AddImport("$(PtvsTargetsFile)").Condition = "Exists($(PtvsTargetsFile))";
projectXml.AddImport(CommonTargets).Condition = "!Exists($(PtvsTargetsFile))";
log(__VSUL_ERRORLEVEL.VSUL_INFORMATIONAL, SR.GetString(SR.UpgradedRemoveCommonTargets));
}
}
示例6: Process
public override void Process(
ProjectRootElement project,
Dictionary<string, ProjectPropertyGroupElement> groups
) {
project.AddImport(@"$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\Python Tools\Microsoft.PythonTools.targets");
}
示例7: ProcessImportsFrom22
private static void ProcessImportsFrom22(ProjectRootElement projectXml, Action<__VSUL_ERRORLEVEL, string> log) {
bool anyUpdated = false;
var propValue = PtvsTargets;
foreach (var p in projectXml.Properties.Where(IsPtvsTargetsFileProperty).ToArray()) {
propValue = p.Value;
p.Parent.RemoveChild(p);
anyUpdated = true;
}
// Replace:
// <Import Condition="Exists($(PtvsTargetsFile))" Project="$(PtvsTargetsFile)" />
// <Import Condition="!Exists($(PtvsTargetsFile))" Project="$(MSBuildToolsPath)\Microsoft.Common.targets" />
//
// With:
// <Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\Python Tools\Microsoft.PythonTools.targets" />
foreach (var p in projectXml.Imports.Where(i => i.Condition.Contains("$(PtvsTargetsFile)") || i.Project.Equals("$(PtvsTargetsFile)")).ToArray()) {
p.Parent.RemoveChild(p);
}
if (ContainsProjectTypeGuid(projectXml, UwpProjectGuid)) {
projectXml.AddImport(UwpTargets);
} else {
projectXml.AddImport(PtvsTargets);
}
if (anyUpdated) {
log(__VSUL_ERRORLEVEL.VSUL_INFORMATIONAL, Strings.UpgradedImportsFor30);
}
}
示例8: CreateBuildProject
void CreateBuildProject()
{
string projectPath = Path.Combine(buildDirectory, "content.contentproj");
string outputPath = Path.Combine(buildDirectory, "bin");
projectRootElement = ProjectRootElement.Create(projectPath);
//projectRootElement.AddImport(@"$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.targets");
projectRootElement.AddImport("$(MSBuildExtensionsPath)\\Microsoft\\XNA Game Studio\\" +
"v4.0\\Microsoft.Xna.GameStudio.ContentPipeline.targets");
buildProject = new Project(projectRootElement);
buildProject.SetProperty("XnaPlatform", "Windows");
buildProject.SetProperty("XnaProfile", "Reach");
//buildProject.SetProperty("Platform", "x86");
buildProject.SetProperty("XnaFrameworkVersion", "v4.0");
buildProject.SetProperty("TargetFrameworkVersion", "v4.0");
buildProject.SetProperty("Configuration", "Release");
buildProject.SetProperty("OutputPath", outputPath);
foreach (string pipelineAssembly in pipelineAssemblies)
{
buildProject.AddItem("Reference", pipelineAssembly);
}
errorLogger = new ErrorLogger();
buildParameters = new BuildParameters(ProjectCollection.GlobalProjectCollection);
buildParameters.Loggers = new ILogger[] { errorLogger };
}
示例9: AddImports
private void AddImports(ProjectRootElement project, IEnumerable<string> modulePaths)
{
foreach (ProjectImportElement import in modulePaths.Where(i => !String.IsNullOrWhiteSpace(i)).Select(modulePath => project.AddImport(Path.Combine(modulePath, ImportRelativePath))))
{
import.Condition = $"Exists('{import.Project}')";
}
}
示例10: CreateBuildProject
/// <summary>
/// Creates a temporary MSBuild content project in memory.
/// </summary>
void CreateBuildProject()
{
string projectPath = Path.Combine(buildDirectory, "content.contentproj");
string outputPath = Path.Combine(buildDirectory, "bin");
// Create the build project.
projectRootElement = ProjectRootElement.Create(projectPath);
// Include the standard targets file that defines how to build XNA Framework content.
projectRootElement.AddImport("$(MSBuildExtensionsPath)\\Microsoft\\XNA Game Studio\\" +
"v4.0\\Microsoft.Xna.GameStudio.ContentPipeline.targets");
buildProject = new Project(projectRootElement);
ProjectItemGroupElement teste = projectRootElement.AddItemGroup();
teste.AddItem("ProjectReference", @"C:\Users\Renann\Desktop\StrategyGame\StrategyGameLibrary\StrategyGameLibrary.csproj");
buildProject.SetProperty("XnaPlatform", "Windows");
buildProject.SetProperty("XnaProfile", "Reach");
buildProject.SetProperty("XnaFrameworkVersion", "v4.0");
buildProject.SetProperty("Configuration", "Release");
buildProject.SetProperty("OutputPath", outputPath);
// Register any custom importers or processors.
foreach (string pipelineAssembly in pipelineAssemblies)
{
buildProject.AddItem("Reference", pipelineAssembly);
}
// Hook up our custom error logger.
errorLogger = new ErrorLogger();
buildParameters = new BuildParameters(ProjectCollection.GlobalProjectCollection);
buildParameters.Loggers = new ILogger[] { errorLogger };
}
示例11: ProcessImportsFrom21b
private static void ProcessImportsFrom21b(ProjectRootElement projectXml, Action<__VSUL_ERRORLEVEL, string> log) {
var bottleImports = projectXml.Imports.Where(p => p.Project.Equals(Ptvs21BetaBottleTargets, StringComparison.OrdinalIgnoreCase)).ToList();
var flaskImports = projectXml.Imports.Where(p => p.Project.Equals(Ptvs21BetaFlaskTargets, StringComparison.OrdinalIgnoreCase)).ToList();
foreach (var import in bottleImports.Concat(flaskImports)) {
import.Project = WebTargets;
}
if (bottleImports.Any()) {
var globals = projectXml.PropertyGroups.FirstOrDefault() ?? projectXml.AddPropertyGroup();
AddOrSetProperty(globals, "PythonDebugWebServerCommandArguments", "--debug $(CommandLineArguments)");
AddOrSetProperty(globals, "PythonWsgiHandler", "{StartupModule}.wsgi_app()");
log(__VSUL_ERRORLEVEL.VSUL_INFORMATIONAL, Strings.UpgradedBottleImports);
}
if (flaskImports.Any()) {
var globals = projectXml.PropertyGroups.FirstOrDefault() ?? projectXml.AddPropertyGroup();
AddOrSetProperty(globals, "PythonWsgiHandler", "{StartupModule}.wsgi_app");
log(__VSUL_ERRORLEVEL.VSUL_INFORMATIONAL, Strings.UpgradedFlaskImports);
}
var commonPropsImports = projectXml.Imports.Where(p => p.Project.Equals(CommonProps, StringComparison.OrdinalIgnoreCase)).ToList();
foreach (var p in commonPropsImports) {
projectXml.RemoveChild(p);
log(__VSUL_ERRORLEVEL.VSUL_INFORMATIONAL, Strings.UpgradedRemoveCommonProps);
}
if (projectXml.Imports.Count == 1 && projectXml.Imports.First().Project.Equals(CommonTargets, StringComparison.OrdinalIgnoreCase)) {
projectXml.RemoveChild(projectXml.Imports.First());
projectXml.AddImport(PtvsTargets);
log(__VSUL_ERRORLEVEL.VSUL_INFORMATIONAL, Strings.UpgradedRemoveCommonTargets);
}
}
示例12: CreateBuildProject
/// <summary>
/// Creates a temporary MSBuild content project in memory.
/// </summary>
void CreateBuildProject()
{
string projectPath = Path.Combine(buildDirectory, "content.contentproj");
string outputPath = Path.Combine(buildDirectory, "bin");
// Create the build project.
projectRootElement = ProjectRootElement.Create(projectPath);
// Include the standard targets file that defines how to build XNA Framework content.
projectRootElement.AddImport("$(MSBuildExtensionsPath)\\Microsoft\\XNA Game Studio\\" +
"v4.0\\Microsoft.Xna.GameStudio.ContentPipeline.targets");
buildProject = new Project(projectRootElement);
buildProject.SetProperty("XnaPlatform", "Windows");
buildProject.SetProperty("XnaProfile", "Reach");
buildProject.SetProperty("XnaFrameworkVersion", "v4.0");
buildProject.SetProperty("Configuration", "Release");
buildProject.SetProperty("OutputPath", outputPath);
// Register any custom importers or processors.
foreach (string pipelineAssembly in pipelineAssemblies)
{
buildProject.AddItem("Reference", pipelineAssembly);
}
buildParameters = new BuildParameters(ProjectCollection.GlobalProjectCollection);
}