本文整理汇总了C#中Microsoft.Build.BuildEngine.Project.AddNewImport方法的典型用法代码示例。如果您正苦于以下问题:C# Project.AddNewImport方法的具体用法?C# Project.AddNewImport怎么用?C# Project.AddNewImport使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Build.BuildEngine.Project
的用法示例。
在下文中一共展示了Project.AddNewImport方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ConditionGet_Null
public void ConditionGet_Null()
{
string importPath = string.Empty;
try
{
importPath = ObjectModelHelpers.CreateFileInTempProjectDirectory("import.proj", TestData.Content3SimpleTargetsDefaultSpecified);
Project p = new Project();
p.AddNewImport(importPath, null);
object o = p.EvaluatedProperties;
Import import = CompatibilityTestHelpers.FindFirstMatchingImportByPath(p.Imports, importPath);
Assertion.AssertNull(import.Condition);
}
finally
{
CompatibilityTestHelpers.RemoveFile(importPath);
}
}
示例2: ImportsUsingTask
public void ImportsUsingTask()
{
string importPath = String.Empty;
try
{
importPath = ObjectModelHelpers.CreateFileInTempProjectDirectory("import.proj", TestData.Content3SimpleTargetsDefaultSpecified);
Project p = new Project();
p.Save(importPath); // required to reproduce
importPath = ObjectModelHelpers.CreateFileInTempProjectDirectory("import.proj", TestData.ContentUsingTaskFile);
Project p2 = new Project(); // new Engine() here fixes testcase
p2.AddNewImport(importPath, "true");
object o = p2.EvaluatedProperties; // evaluate the import
Assertion.AssertNull(CompatibilityTestHelpers.FindUsingTaskByName("TaskName", p2.UsingTasks)); // fails to find task
}
finally
{
CompatibilityTestHelpers.RemoveFile(importPath);
}
}
示例3: IsImported_true
public void IsImported_true()
{
string importPath = String.Empty;
try
{
importPath = ObjectModelHelpers.CreateFileInTempProjectDirectory("import.proj", TestData.ContentUsingTaskName);
Project p = new Project(new Engine());
p.AddNewImport(importPath, "true");
Object o = p.EvaluatedProperties;
Import import = CompatibilityTestHelpers.FindFirstMatchingImportByPath(p.Imports, importPath);
import.Condition = null;
Assertion.AssertEquals(true, CompatibilityTestHelpers.FindUsingTaskByName("TaskName", p.UsingTasks).IsImported);
}
finally
{
CompatibilityTestHelpers.RemoveFile(importPath);
}
}
示例4: Execute
//.........这里部分代码省略.........
pg.Condition = "'$(Configuration)|$(Platform)' == 'Release|AnyCPU'";
pg.AddNewProperty("DebugType", "pdbonly");
pg.AddNewProperty("Optimize", "true");
pg.AddNewProperty("OutputPath", "bin\\release");
pg.AddNewProperty("DefineConstants", "TRACE");
pg.AddNewProperty("ErrorReport", "prompt");
pg.AddNewProperty("WarningLevel", "4");
pg.AddNewProperty("DocumentationFile", "bin\\release\\" + parameters["rimbapi-target-ns"][0] + ".xml");
// Create Dir Structure
Directory.CreateDirectory(Path.Combine(hostContext.Output, "bin"));
Directory.CreateDirectory(Path.Combine(hostContext.Output, "lib"));
Directory.CreateDirectory(Path.Combine(hostContext.Output, "Properties"));
Directory.CreateDirectory(Path.Combine(hostContext.Output, "Vocabulary"));
Directory.CreateDirectory(Path.Combine(hostContext.Output, "Interaction"));
// Add reference structure
Microsoft.Build.BuildEngine.BuildItemGroup refItemGroup = project.AddNewItemGroup();
// Add References
File.Copy(Path.Combine(System.Windows.Forms.Application.StartupPath, "MARC.Everest.dll"), Path.Combine(Path.Combine(hostContext.Output, "lib"), "MARC.Everest.dll"), true);
if(makeWP7Proj)
File.Copy(Path.Combine(Path.Combine(System.Windows.Forms.Application.StartupPath, "lib"), "MARC.Everest.Phone.dll"), Path.Combine(Path.Combine(hostContext.Output, "lib"), "MARC.Everest.Phone.dll"), true);
File.Copy(Path.Combine(System.Windows.Forms.Application.StartupPath, "MARC.Everest.xml"), Path.Combine(Path.Combine(hostContext.Output, "lib"), "MARC.Everest.xml"), true);
refItemGroup.AddNewItem("Reference", "System");
refItemGroup.AddNewItem("Reference", "System.Drawing");
refItemGroup.AddNewItem("Reference", "System.Xml");
Microsoft.Build.BuildEngine.BuildItem buildItem = refItemGroup.AddNewItem("Reference", @"MARC.Everest");
buildItem.SetMetadata("SpecificVersion", "false");
buildItem.SetMetadata("HintPath", "lib\\MARC.Everest.dll");
project.AddNewImport("$(MSBuildBinPath)\\Microsoft.CSharp.targets", null);
Microsoft.Build.BuildEngine.BuildItemGroup fileItemGroup = project.AddNewItemGroup(),
phoneFileItemGroup = phoneProj.AddNewItemGroup();
#region Assembly Info
try
{
TextWriter tw = File.CreateText(Path.Combine(Path.Combine(hostContext.Output, "Properties"), "AssemblyInfo.cs"));
try
{
string Header = Template.AssemblyInfo; // Set the header to the default
// Populate template fields
foreach (String[] st in templateFields)
Header = Header.Replace(st[0], st[1]);
// Write header
tw.Write(Header);
}
finally
{
tw.Close();
}
fileItemGroup.AddNewItem("Compile", Path.Combine("Properties", "AssemblyInfo.cs"));
phoneFileItemGroup.AddNewItem("Compile", Path.Combine("Properties", "AssemblyInfo.cs"));
}
catch(Exception)
{
System.Diagnostics.Trace.WriteLine("Couldn't generate the AssemblyInfo.cs file for this project", "warn");
}
#endregion
#endregion
示例5: 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 engine.
msBuildEngine = new Engine(RuntimeEnvironment.GetRuntimeDirectory());
// Hook up our custom error logger.
errorLogger = new ErrorLogger();
msBuildEngine.RegisterLogger(errorLogger);
// Create the build project.
msBuildProject = new Project(msBuildEngine);
msBuildProject.FullFileName = projectPath;
msBuildProject.SetProperty("XnaPlatform", "Windows");
msBuildProject.SetProperty("XnaFrameworkVersion", "v2.0");
msBuildProject.SetProperty("Configuration", "Release");
msBuildProject.SetProperty("OutputPath", outputPath);
// Register any custom importers or processors.
foreach (string pipelineAssembly in pipelineAssemblies)
{
msBuildProject.AddNewItem("Reference", pipelineAssembly);
}
// Include the standard targets file that defines
// how to build XNA Framework content.
msBuildProject.AddNewImport("$(MSBuildExtensionsPath)\\Microsoft\\XNA " +
"Game Studio\\v3.1\\Microsoft.Xna.GameStudio" +
".ContentPipeline.targets", null);
}
示例6: 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 engine.
msBuildEngine = new Engine();
// Hook up our custom error logger.
errorLogger = new ErrorLogger();
msBuildEngine.RegisterLogger(errorLogger);
msBuildEngine.DefaultToolsVersion = "3.5";
// Create the build project.
msBuildProject = new Project(msBuildEngine);
msBuildProject.FullFileName = projectPath;
msBuildProject.SetProperty("XnaPlatform", "Windows");
msBuildProject.SetProperty("XnaFrameworkVersion", "v3.1");
msBuildProject.SetProperty("Configuration", "Release");
msBuildProject.SetProperty("OutputPath", outputPath);
// Register any custom importers or processors.
foreach (string pipelineAssembly in pipelineAssemblies)
{
msBuildProject.AddNewItem("Reference", pipelineAssembly);
}
// Reference SkinnedModelPipeline.
string applicationDirectory = AppDomain.CurrentDomain.BaseDirectory;
string dllPath = Path.Combine(applicationDirectory, "SkinnedModelPipeline.dll");
string importDll = Path.GetFullPath(dllPath);
this.msBuildProject.AddNewItem("Reference", importDll);
// Include the standard targets file that defines
// how to build XNA Framework content.
msBuildProject.AddNewImport("$(MSBuildExtensionsPath)\\Microsoft\\XNA " +
"Game Studio\\v3.1\\Microsoft.Xna.GameStudio" +
".ContentPipeline.targets", null);
}
示例7: ConfigureProject
protected virtual void ConfigureProject(Project proj)
{
_globalProperties = proj.AddNewPropertyGroup(false);
_globalProperties.AddNewProperty("OutputType", "Library");
_globalProperties.AddNewProperty("AssemblyName", AssemblyName);
_globalProperties.AddNewProperty("OutputPath", OutputPath);
_globalProperties.AddNewProperty("Optimize", "true");
_globalProperties.AddNewProperty("NoWarn", "1591,0168");
_globalProperties.AddNewProperty("DocumentationFile", string.Concat(OutputPath, "\\", AssemblyName, ".XML"));
proj.AddNewImport(@"$(MSBuildBinPath)\Microsoft.CSharp.targets", String.Empty);
_references = proj.AddNewItemGroup();
}
示例8: ProjectPathSet_ScalarValue
public void ProjectPathSet_ScalarValue()
{
string importPath = String.Empty;
string importPath2 = String.Empty;
try
{
importPath = ObjectModelHelpers.CreateFileInTempProjectDirectory("import.proj", TestData.Content3SimpleTargetsDefaultSpecified);
importPath2 = ObjectModelHelpers.CreateFileInTempProjectDirectory("import2.proj", TestData.Content3SimpleTargetsDefaultSpecified);
Project p = new Project();
p.AddNewImport(importPath, "true");
p.SetProperty("path", importPath2);
object o = p.EvaluatedProperties;
BuildProperty path = CompatibilityTestHelpers.FindBuildProperty(p, "path");
Import import = CompatibilityTestHelpers.FindFirstMatchingImportByPath(p.Imports, importPath);
import.ProjectPath = "$(path)";
Assertion.AssertEquals("$(path)", import.ProjectPath);
o = p.EvaluatedProperties;
Assertion.AssertEquals(false, object.Equals(importPath2, import.EvaluatedProjectPath)); // V9 OM does not evaluate imports
}
finally
{
CompatibilityTestHelpers.RemoveFile(importPath);
CompatibilityTestHelpers.RemoveFile(importPath2);
}
}
示例9: ProjectPathGetWhenSetInCtor
public void ProjectPathGetWhenSetInCtor()
{
string importPath = String.Empty;
try
{
importPath = ObjectModelHelpers.CreateFileInTempProjectDirectory("import.proj", TestData.Content3SimpleTargetsDefaultSpecified);
Project p = new Project();
p.AddNewImport(importPath, "true");
object o = p.EvaluatedProperties;
// The verbosity of this assertion is to abstract the internal implentation of FindFirstMatchingImportByPath.
Assertion.AssertEquals(importPath, CompatibilityTestHelpers.FindFirstMatchingImportByPath(p.Imports, importPath).ProjectPath);
}
finally
{
CompatibilityTestHelpers.RemoveFile(importPath);
}
}
示例10: ProjectPathSet_Escaped
public void ProjectPathSet_Escaped()
{
string importPath = String.Empty;
try
{
importPath = ObjectModelHelpers.CreateFileInTempProjectDirectory("import.proj", TestData.Content3SimpleTargetsDefaultSpecified);
Project p = new Project();
p.AddNewImport(importPath, "true");
object o = p.EvaluatedProperties;
Import import = CompatibilityTestHelpers.FindFirstMatchingImportByPath(p.Imports, importPath);
import.ProjectPath = @"%25%2a%3f%40%24%28%29%3b\";
Assertion.AssertEquals(@"%25%2a%3f%40%24%28%29%3b\", import.ProjectPath);
}
finally
{
CompatibilityTestHelpers.RemoveFile(importPath);
}
}
示例11: ConditionSet_DirtyWhenSet
public void ConditionSet_DirtyWhenSet()
{
string projectPath = String.Empty;
string importPath = String.Empty;
try
{
projectPath = ObjectModelHelpers.CreateFileInTempProjectDirectory("project.proj", TestData.Content3SimpleTargetsDefaultSpecified);
importPath = ObjectModelHelpers.CreateFileInTempProjectDirectory("import.proj", TestData.Content3SimpleTargetsDefaultSpecified);
Project p = new Project();
p.AddNewImport(importPath, "true");
object o = p.EvaluatedProperties;
Import import = CompatibilityTestHelpers.FindFirstMatchingImportByPath(p.Imports, importPath);
p.Save(projectPath);
Assertion.AssertEquals(false, p.IsDirty);
import.Condition = "condition";
Assertion.AssertEquals(true, p.IsDirty);
}
finally
{
CompatibilityTestHelpers.RemoveFile(importPath);
CompatibilityTestHelpers.RemoveFile(projectPath);
}
}
示例12: AddNewImportOverload
/// <summary>
/// Indirection for common tests to p.AddNewImport
/// </summary>
private void AddNewImportOverload(Project p, string path, string condition)
{
p.AddNewImport(path, condition);
}
示例13: ImportsGet
public void ImportsGet()
{
string importPath = String.Empty;
try
{
Project p = new Project(new Engine());
importPath = ObjectModelHelpers.CreateTempFileOnDisk(TestData.ContentSimpleTools35InitialTargets);
p.AddNewImport(importPath, null);
object o = p.EvaluatedItems; // force evaluation of imported projects.
Assertion.AssertEquals(1, p.Imports.Count);
}
finally
{
CompatibilityTestHelpers.RemoveFile(importPath);
}
}
示例14: AddNewPropertyGroupNotAFter
public void AddNewPropertyGroupNotAFter()
{
Project p = new Project();
p.AddNewImport("p", "c");
BuildPropertyGroup buildPropertyGroup1 = p.AddNewPropertyGroup(false);
Assertion.AssertEquals(true, p.Xml.IndexOf("<PropertyGroup />") < p.Xml.IndexOf("<Import Condition=\"c\" Project=\"p\" />"));
}
示例15: AddNewPropertyGroupBeforeOneOtherPropertyGroupAndAUsingTask
public void AddNewPropertyGroupBeforeOneOtherPropertyGroupAndAUsingTask()
{
Project p = new Project();
BuildPropertyGroup buildPropertyGroup1 = p.AddNewPropertyGroup(true);
buildPropertyGroup1.Condition = "true";
p.AddNewImport("p", "c");
BuildPropertyGroup buildPropertyGroup2 = p.AddNewPropertyGroup(false);
buildPropertyGroup2.Condition = "false";
Assertion.AssertEquals(true, p.Xml.IndexOf("<PropertyGroup Condition=\"true\" />") < p.Xml.IndexOf("<PropertyGroup Condition=\"false\" />"));
Assertion.AssertEquals(true, p.Xml.IndexOf("<PropertyGroup Condition=\"true\" />") < p.Xml.IndexOf("<Import Condition=\"c\" Project=\"p\" />"));
Assertion.AssertEquals(2, p.PropertyGroups.Count);
}