本文整理汇总了C#中ProjectFileCollection.Add方法的典型用法代码示例。如果您正苦于以下问题:C# ProjectFileCollection.Add方法的具体用法?C# ProjectFileCollection.Add怎么用?C# ProjectFileCollection.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ProjectFileCollection
的用法示例。
在下文中一共展示了ProjectFileCollection.Add方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetContents
protected void GetContents (MonoDevelop.Projects.Project project, MonoDevelop.Prj2Make.Schema.Csproj.File[] Include, ProjectFileCollection files, IProgressMonitor monitor)
{
if (Include == null || Include.Length == 0)
return;
// Iterate through the file collection of the csproj file
foreach(MonoDevelop.Prj2Make.Schema.Csproj.File fl in Include)
{
ProjectFile flOut = new ProjectFile ();
string name;
if ((fl.Link == null) || (fl.Link.Length == 0)) {
name = MapPath (project.BaseDirectory, fl.RelPath);
} else {
name = MapPath (null, fl.Link);
}
if (name == null) {
monitor.ReportWarning (GettextCatalog.GetString ("Can't import file: ") + fl.RelPath);
continue;
}
flOut.Name = name;
// Adding here as GetDefaultResourceIdInternal needs flOut.Project
files.Add (flOut);
switch (fl.SubType)
{
case "Code":
flOut.Subtype = Subtype.Code;
break;
}
switch (fl.BuildAction)
{
case MonoDevelop.Prj2Make.Schema.Csproj.FileBuildAction.Compile:
flOut.BuildAction = BuildAction.Compile;
break;
case MonoDevelop.Prj2Make.Schema.Csproj.FileBuildAction.Content:
flOut.BuildAction = BuildAction.Content;
break;
case MonoDevelop.Prj2Make.Schema.Csproj.FileBuildAction.EmbeddedResource:
flOut.BuildAction = BuildAction.EmbeddedResource;
break;
case MonoDevelop.Prj2Make.Schema.Csproj.FileBuildAction.None:
flOut.BuildAction = BuildAction.None;
break;
}
// DependentUpon is relative to flOut
flOut.DependsOn = MapPath (Path.GetDirectoryName (flOut.Name), fl.DependentUpon);
flOut.Data = "";
}
}
示例2: GetFolderContent
void GetFolderContent(Project project, string folder, out ProjectFileCollection files, out List<string> folders)
{
string folderPrefix = folder + Path.DirectorySeparatorChar;
files = new ProjectFileCollection ();
folders = new List<string> ();
foreach (ProjectFile file in project.Files)
{
string dir;
if (file.Subtype != Subtype.Directory) {
if (file.DependsOnFile != null)
continue;
dir = file.IsLink
? project.BaseDirectory.Combine (file.ProjectVirtualPath).ParentDirectory
: file.FilePath.ParentDirectory;
if (dir == folder) {
files.Add (file);
continue;
}
} else
dir = file.Name;
// add the directory if it isn't already present
if (dir.StartsWith (folderPrefix, StringComparison.Ordinal)) {
int i = dir.IndexOf (Path.DirectorySeparatorChar, folderPrefix.Length);
if (i != -1) dir = dir.Substring (0,i);
if (!folders.Contains (dir))
folders.Add (dir);
}
}
}
示例3: Compile
public BuildResult Compile(ProjectItemCollection items, DotNetProjectConfiguration configuration, IProgressMonitor monitor)
{
FSharpCompilerParameters compilerparameters = (FSharpCompilerParameters) configuration.CompilationParameters;
if (compilerparameters == null) compilerparameters = new FSharpCompilerParameters ();
string responseFileName = Path.GetTempFileName();
StringWriter writer = new StringWriter ();
ArrayList gacRoots = new ArrayList ();
AddOption(writer, "--fullpaths");
AddOption(writer, "--utf8output");
ProjectFileCollection projectFiles = new ProjectFileCollection();
ProjectReferenceCollection references = new ProjectReferenceCollection();
// FIXME: Plain guesswork
foreach(ProjectItem item in items)
{
ProjectFile file = null;
ProjectReference reference = null;
if((file = item as ProjectFile) != null)
{
projectFiles.Add(file);
}
else if((reference = item as ProjectReference) != null)
{
references.Add(reference);
}
else
{
// Nada...
}
}
if (references != null) {
foreach (ProjectReference lib in references) {
if ((lib.ReferenceType == ReferenceType.Project) &&
(!(lib.OwnerProject.ParentSolution.FindProjectByName (lib.Reference) is DotNetProject)))
continue;
foreach (string fileName in lib.GetReferencedFileNames (configuration.Id)) {
switch (lib.ReferenceType) {
case ReferenceType.Gac:
SystemPackage[] pkgs = Runtime.SystemAssemblyService.GetPackagesFromFullName(lib.Reference);
SystemPackage pkg = null;
if(pkgs != null && pkgs.Length > 0)
{
// FIXME: Now handling only one package
pkg = pkgs[0];
}
if (pkg == null) {
string msg = String.Format (GettextCatalog.GetString ("{0} could not be found or is invalid."), lib.Reference);
monitor.ReportWarning (msg);
continue;
}
else if (pkg.IsInternalPackage) {
AddOption(writer,"-r \"" + fileName + "\"");
}
if (pkg.GacRoot != null && !gacRoots.Contains (pkg.GacRoot))
gacRoots.Add (pkg.GacRoot);
break;
default:
AddOption(writer,"-r \"" + fileName + "\"");
break;
}
}
}
}
string exe = configuration.CompiledOutputName;
AddOption(writer,"--out \"" + exe + '"');
if (configuration.SignAssembly) {
if (File.Exists (configuration.AssemblyKeyFile))
AddOption(writer,"--keyfile \"" + configuration.AssemblyKeyFile + '"');
}
if (configuration.DebugMode) {
AddOption(writer,"--debug");
}
else
if (compilerparameters.Optimize)
AddOption(writer,"--optimize");
if (compilerparameters.CodePage != 0) {
AddOption(writer,"--codepage " + compilerparameters.CodePage);
}
if (compilerparameters.TreatWarningsAsErrors) {
AddOption(writer,"--warnaserror");
}
if (compilerparameters.DefineSymbols.Length > 0) {
AddOption(writer,"--define " + compilerparameters.DefineSymbols);
}
switch (configuration.CompileTarget) {
case CompileTarget.Exe:
AddOption(writer,"--target exe");
break;
case CompileTarget.WinExe:
//.........这里部分代码省略.........