update prebuild
This commit is contained in:
@@ -315,6 +315,67 @@ namespace Prebuild.Core.Nodes
|
||||
}
|
||||
}
|
||||
|
||||
[OptionNode("EnableDefaultItems")]
|
||||
private bool m_EnableDefaultItems = true;
|
||||
|
||||
public bool EnableDefaultItems
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_EnableDefaultItems;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_EnableDefaultItems = value;
|
||||
}
|
||||
}
|
||||
|
||||
[OptionNode("UseCommonOutputDirectory")]
|
||||
private bool m_UseCommonOutputDirectory = false;
|
||||
|
||||
public bool UseCommonOutputDirectory
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_UseCommonOutputDirectory;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_UseCommonOutputDirectory = value;
|
||||
}
|
||||
}
|
||||
|
||||
[OptionNode("AppendTargetFrameworkToOutputPath")]
|
||||
private bool m_AppendTargetFrameworkToOutputPath = true;
|
||||
|
||||
public bool AppendTargetFrameworkToOutputPath
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_AppendTargetFrameworkToOutputPath;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_AppendTargetFrameworkToOutputPath = value;
|
||||
}
|
||||
}
|
||||
|
||||
[OptionNode("AppendRuntimeIdentifierToOutputPath")]
|
||||
private bool m_AppendRuntimeIdentifierToOutputPath = true;
|
||||
|
||||
public bool AppendRuntimeIdentifierToOutputPath
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_AppendRuntimeIdentifierToOutputPath;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_AppendRuntimeIdentifierToOutputPath = value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[OptionNode("OutputPath")]
|
||||
private string m_OutputPath = "bin/";
|
||||
|
||||
|
||||
151
Prebuild/src/Core/Targets/VS2017Target.cs
Normal file
151
Prebuild/src/Core/Targets/VS2017Target.cs
Normal file
@@ -0,0 +1,151 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
using Prebuild.Core.Attributes;
|
||||
using Prebuild.Core.Interfaces;
|
||||
using Prebuild.Core.Nodes;
|
||||
using Prebuild.Core.Utilities;
|
||||
using System.CodeDom.Compiler;
|
||||
|
||||
namespace Prebuild.Core.Targets
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
[Target("vs2017")]
|
||||
public class VS2017Target : VSGenericTarget
|
||||
{
|
||||
#region Fields
|
||||
|
||||
string solutionVersion = "12.00";
|
||||
string productVersion = "15.9.50";
|
||||
string schemaVersion = "2.0";
|
||||
string versionName = "Visual Studio 17";
|
||||
string name = "vs2017";
|
||||
VSVersion version = VSVersion.VS17;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the solution version.
|
||||
/// </summary>
|
||||
/// <value>The solution version.</value>
|
||||
public override string SolutionVersion
|
||||
{
|
||||
get
|
||||
{
|
||||
return solutionVersion;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the product version.
|
||||
/// </summary>
|
||||
/// <value>The product version.</value>
|
||||
public override string ProductVersion
|
||||
{
|
||||
get
|
||||
{
|
||||
return productVersion;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the schema version.
|
||||
/// </summary>
|
||||
/// <value>The schema version.</value>
|
||||
public override string SchemaVersion
|
||||
{
|
||||
get
|
||||
{
|
||||
return schemaVersion;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the name of the version.
|
||||
/// </summary>
|
||||
/// <value>The name of the version.</value>
|
||||
public override string VersionName
|
||||
{
|
||||
get
|
||||
{
|
||||
return versionName;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the version.
|
||||
/// </summary>
|
||||
/// <value>The version.</value>
|
||||
public override VSVersion Version
|
||||
{
|
||||
get
|
||||
{
|
||||
return version;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name.
|
||||
/// </summary>
|
||||
/// <value>The name.</value>
|
||||
public override string Name
|
||||
{
|
||||
get
|
||||
{
|
||||
return name;
|
||||
}
|
||||
}
|
||||
|
||||
protected override string GetToolsVersionXml(FrameworkVersion frameworkVersion)
|
||||
{
|
||||
switch (frameworkVersion)
|
||||
{
|
||||
case FrameworkVersion.v4_8:
|
||||
case FrameworkVersion.v4_7_2:
|
||||
case FrameworkVersion.v4_7_1:
|
||||
case FrameworkVersion.v4_7:
|
||||
return "ToolsVersion=\"15.0\"";
|
||||
case FrameworkVersion.v4_6_2:
|
||||
case FrameworkVersion.v4_6_1:
|
||||
case FrameworkVersion.v4_6:
|
||||
return "ToolsVersion=\"14.0\"";
|
||||
case FrameworkVersion.v4_5_2:
|
||||
return "ToolsVersion=\"12.0\"";
|
||||
case FrameworkVersion.v4_5_1:
|
||||
case FrameworkVersion.v4_5:
|
||||
case FrameworkVersion.v4_0:
|
||||
case FrameworkVersion.v3_5:
|
||||
return "ToolsVersion=\"4.0\"";
|
||||
case FrameworkVersion.v3_0:
|
||||
return "ToolsVersion=\"3.0\"";
|
||||
default:
|
||||
return "ToolsVersion=\"2.0\"";
|
||||
}
|
||||
}
|
||||
|
||||
public override string SolutionTag
|
||||
{
|
||||
get { return "# Visual Studio 17"; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="VS2012Target"/> class.
|
||||
/// </summary>
|
||||
public VS2017Target()
|
||||
: base()
|
||||
{
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -106,6 +106,10 @@ namespace Prebuild.Core.Targets
|
||||
{
|
||||
switch (frameworkVersion)
|
||||
{
|
||||
case FrameworkVersion.netstandard2_0:
|
||||
case FrameworkVersion.net5_0:
|
||||
case FrameworkVersion.net6_0:
|
||||
case FrameworkVersion.net7_0:
|
||||
case FrameworkVersion.v4_8:
|
||||
case FrameworkVersion.v4_7_2:
|
||||
return "ToolsVersion=\"16.0\"";
|
||||
|
||||
157
Prebuild/src/Core/Targets/VS2022Target.cs
Normal file
157
Prebuild/src/Core/Targets/VS2022Target.cs
Normal file
@@ -0,0 +1,157 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
using Prebuild.Core.Attributes;
|
||||
using Prebuild.Core.Interfaces;
|
||||
using Prebuild.Core.Nodes;
|
||||
using Prebuild.Core.Utilities;
|
||||
using System.CodeDom.Compiler;
|
||||
|
||||
namespace Prebuild.Core.Targets
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
[Target("vs2022")]
|
||||
public class VS2022Target : VSGenericTarget
|
||||
{
|
||||
#region Fields
|
||||
|
||||
string solutionVersion = "12.00";
|
||||
string productVersion = "117.3.2";
|
||||
string schemaVersion = "2.0";
|
||||
string versionName = "Visual Studio Version 17";
|
||||
string name = "vs2022";
|
||||
VSVersion version = VSVersion.VS22;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the solution version.
|
||||
/// </summary>
|
||||
/// <value>The solution version.</value>
|
||||
public override string SolutionVersion
|
||||
{
|
||||
get
|
||||
{
|
||||
return solutionVersion;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the product version.
|
||||
/// </summary>
|
||||
/// <value>The product version.</value>
|
||||
public override string ProductVersion
|
||||
{
|
||||
get
|
||||
{
|
||||
return productVersion;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the schema version.
|
||||
/// </summary>
|
||||
/// <value>The schema version.</value>
|
||||
public override string SchemaVersion
|
||||
{
|
||||
get
|
||||
{
|
||||
return schemaVersion;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the name of the version.
|
||||
/// </summary>
|
||||
/// <value>The name of the version.</value>
|
||||
public override string VersionName
|
||||
{
|
||||
get
|
||||
{
|
||||
return versionName;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the version.
|
||||
/// </summary>
|
||||
/// <value>The version.</value>
|
||||
public override VSVersion Version
|
||||
{
|
||||
get
|
||||
{
|
||||
return version;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name.
|
||||
/// </summary>
|
||||
/// <value>The name.</value>
|
||||
public override string Name
|
||||
{
|
||||
get
|
||||
{
|
||||
return name;
|
||||
}
|
||||
}
|
||||
|
||||
protected override string GetToolsVersionXml(FrameworkVersion frameworkVersion)
|
||||
{
|
||||
switch (frameworkVersion)
|
||||
{
|
||||
case FrameworkVersion.net5_0:
|
||||
case FrameworkVersion.net6_0:
|
||||
case FrameworkVersion.net7_0:
|
||||
return "ToolsVersion=\"17.0\"";
|
||||
case FrameworkVersion.netstandard2_0:
|
||||
case FrameworkVersion.v4_8:
|
||||
case FrameworkVersion.v4_7_2:
|
||||
return "ToolsVersion=\"16.0\"";
|
||||
case FrameworkVersion.v4_7_1:
|
||||
case FrameworkVersion.v4_7:
|
||||
return "ToolsVersion=\"15.0\"";
|
||||
case FrameworkVersion.v4_6_2:
|
||||
case FrameworkVersion.v4_6_1:
|
||||
case FrameworkVersion.v4_6:
|
||||
return "ToolsVersion=\"14.0\"";
|
||||
case FrameworkVersion.v4_5_2:
|
||||
return "ToolsVersion=\"12.0\"";
|
||||
case FrameworkVersion.v4_5_1:
|
||||
case FrameworkVersion.v4_5:
|
||||
case FrameworkVersion.v4_0:
|
||||
case FrameworkVersion.v3_5:
|
||||
return "ToolsVersion=\"4.0\"";
|
||||
case FrameworkVersion.v3_0:
|
||||
return "ToolsVersion=\"3.0\"";
|
||||
default:
|
||||
return "ToolsVersion=\"2.0\"";
|
||||
}
|
||||
}
|
||||
|
||||
public override string SolutionTag
|
||||
{
|
||||
get { return "# Visual Studio 22"; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="VS2012Target"/> class.
|
||||
/// </summary>
|
||||
public VS2022Target()
|
||||
: base()
|
||||
{
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -317,7 +317,6 @@ namespace Prebuild.Core.Targets
|
||||
|
||||
}
|
||||
|
||||
|
||||
#region Files
|
||||
foreach (string filePath in project.Files)
|
||||
{
|
||||
@@ -674,6 +673,9 @@ namespace Prebuild.Core.Targets
|
||||
private void WriteProjectDotNet(SolutionNode solution, ProjectNode project, StreamWriter ps)
|
||||
{
|
||||
#region Project File
|
||||
bool listFiles = false;
|
||||
string prebuild = string.Empty;
|
||||
string postbuild = string.Empty;
|
||||
using (ps)
|
||||
{
|
||||
ps.WriteLine("<Project Sdk=\"Microsoft.NET.Sdk\">");
|
||||
@@ -681,12 +683,17 @@ namespace Prebuild.Core.Targets
|
||||
|
||||
ps.WriteLine(" <PropertyGroup>");
|
||||
ps.WriteLine(" <TargetFramework>{0}</TargetFramework>", project.FrameworkVersion.ToString().Replace("_", "."));
|
||||
ps.WriteLine(" <PreserveCompilationContext>false</PreserveCompilationContext>");
|
||||
ps.WriteLine(" <OutputType>{0}</OutputType>", project.Type == ProjectType.Web ? ProjectType.Library.ToString() : project.Type.ToString());
|
||||
ps.WriteLine(" <GenerateAssemblyInfo>false</GenerateAssemblyInfo>");
|
||||
ps.WriteLine(" <RuntimeFrameworkVersion>5.0.0</RuntimeFrameworkVersion>");
|
||||
if(project.FrameworkVersion == FrameworkVersion.netstandard2_0)
|
||||
ps.WriteLine(" <RuntimeFrameworkVersion>5.0.0</RuntimeFrameworkVersion>");
|
||||
ps.WriteLine(" <ImplicitUsings>disable</ImplicitUsings>");
|
||||
ps.WriteLine(" <AssemblyName>{0}</AssemblyName>", project.AssemblyName);
|
||||
ps.WriteLine(" <Deterministic>true</Deterministic>");
|
||||
//ps.WriteLine(" <EnableDefaultCompileItems>false</EnableDefaultCompileItems>");
|
||||
ps.WriteLine(" <ProduceReferenceAssembly>false</ProduceReferenceAssembly>");
|
||||
ps.WriteLine(" <GenerateDependencyFile>false</GenerateDependencyFile>");
|
||||
ps.WriteLine(" </PropertyGroup>");
|
||||
ps.WriteLine();
|
||||
|
||||
@@ -720,6 +727,16 @@ namespace Prebuild.Core.Targets
|
||||
ps.WriteLine(" <FileAlignment>{0}</FileAlignment>", conf.Options["FileAlignment"]);
|
||||
ps.WriteLine(" <Optimize>{0}</Optimize>", conf.Options["OptimizeCode"]);
|
||||
ps.WriteLine(" <TieredCompilation>false</TieredCompilation>");
|
||||
|
||||
ps.WriteLine(" <UseCommonOutputDirectory>{0}</UseCommonOutputDirectory>", conf.Options["UseCommonOutputDirectory"].ToString());
|
||||
ps.WriteLine(" <AppendTargetFrameworkToOutputPath>{0}</AppendTargetFrameworkToOutputPath>", conf.Options["AppendTargetFrameworkToOutputPath"].ToString());
|
||||
ps.WriteLine(" <AppendRuntimeIdentifierToOutputPath>{0}</AppendRuntimeIdentifierToOutputPath>", conf.Options["AppendRuntimeIdentifierToOutputPath"].ToString());
|
||||
if ((bool)conf.Options["EnableDefaultItems"] == false)
|
||||
{
|
||||
listFiles = true;
|
||||
ps.WriteLine(" <EnableDefaultItems>false</EnableDefaultItems>");
|
||||
}
|
||||
|
||||
if (project.Type != ProjectType.Web)
|
||||
ps.WriteLine(" <OutputPath>{0}</OutputPath>",
|
||||
Helper.EndPath(Helper.NormalizePath(conf.Options["OutputPath"].ToString())));
|
||||
@@ -734,6 +751,16 @@ namespace Prebuild.Core.Targets
|
||||
ps.WriteLine(" <NoStdLib>{0}</NoStdLib>", conf.Options["NoStdLib"]);
|
||||
ps.WriteLine(" <NoWarn>{0}</NoWarn>", conf.Options["SuppressWarnings"]);
|
||||
ps.WriteLine(" <PlatformTarget>{0}</PlatformTarget>", conf.Platform);
|
||||
|
||||
if (conf.Options["PreBuildEvent"] != null && conf.Options["PreBuildEvent"].ToString().Length != 0)
|
||||
{
|
||||
prebuild = conf.Options["PreBuildEvent"].ToString();
|
||||
}
|
||||
if (conf.Options["PostBuildEvent"] != null && conf.Options["PostBuildEvent"].ToString().Length != 0)
|
||||
{
|
||||
postbuild = conf.Options["PostBuildEvent"].ToString();
|
||||
}
|
||||
|
||||
ps.WriteLine(" </PropertyGroup>");
|
||||
}
|
||||
}
|
||||
@@ -762,6 +789,200 @@ namespace Prebuild.Core.Targets
|
||||
// Output the ItemGroup for project.References
|
||||
WriteProjectReferencesDotNet(solution, project, ps);
|
||||
|
||||
if (listFiles)
|
||||
{
|
||||
List<string> list = new List<string>();
|
||||
ps.WriteLine(" <ItemGroup>");
|
||||
foreach (string filePath in project.Files)
|
||||
{
|
||||
// Add the filePath with the destination as the key
|
||||
// will use it later to form the copy parameters with Include lists
|
||||
// for each destination
|
||||
if (project.Files.GetBuildAction(filePath) == BuildAction.Copy)
|
||||
continue;
|
||||
// if (file == "Properties\\Bind.Designer.cs")
|
||||
// {
|
||||
// Console.WriteLine("Wait a minute!");
|
||||
// Console.WriteLine(project.Files.GetSubType(file).ToString());
|
||||
// }
|
||||
SubType subType = project.Files.GetSubType(filePath);
|
||||
|
||||
// Visual Studio chokes on file names if forward slash is used as a path separator
|
||||
// instead of backslash. So we must make sure that all file paths written to the
|
||||
// project file use \ as a path separator.
|
||||
string file = filePath.Replace(@"/", @"\");
|
||||
|
||||
if (subType != SubType.Code && subType != SubType.Settings && subType != SubType.Designer
|
||||
&& subType != SubType.CodeBehind)
|
||||
{
|
||||
ps.WriteLine(" <EmbeddedResource Include=\"{0}\">", file.Substring(0, file.LastIndexOf('.')) + ".resx");
|
||||
ps.WriteLine(" <DependentUpon>{0}</DependentUpon>", Path.GetFileName(file));
|
||||
ps.WriteLine(" <SubType>Designer</SubType>");
|
||||
ps.WriteLine(" </EmbeddedResource>");
|
||||
//
|
||||
}
|
||||
|
||||
if (subType == SubType.Designer)
|
||||
{
|
||||
ps.WriteLine(" <EmbeddedResource Include=\"{0}\">", file);
|
||||
|
||||
string autogen_name = file.Substring(0, file.LastIndexOf('.')) + ".Designer.cs";
|
||||
string dependent_name = filePath.Substring(0, file.LastIndexOf('.')) + ".cs";
|
||||
|
||||
// Check for a parent .cs file with the same name as this designer file
|
||||
if (File.Exists(Helper.NormalizePath(dependent_name)))
|
||||
{
|
||||
ps.WriteLine(" <DependentUpon>{0}</DependentUpon>", Path.GetFileName(dependent_name));
|
||||
}
|
||||
else
|
||||
{
|
||||
ps.WriteLine(" <Generator>ResXFileCodeGenerator</Generator>");
|
||||
ps.WriteLine(" <LastGenOutput>{0}</LastGenOutput>", Path.GetFileName(autogen_name));
|
||||
ps.WriteLine(" <SubType>" + subType + "</SubType>");
|
||||
}
|
||||
|
||||
ps.WriteLine(" </EmbeddedResource>");
|
||||
if (File.Exists(Helper.NormalizePath(autogen_name)))
|
||||
{
|
||||
ps.WriteLine(" <Compile Include=\"{0}\">", autogen_name);
|
||||
//ps.WriteLine(" <DesignTime>True</DesignTime>");
|
||||
|
||||
// If a parent .cs file exists, link this autogen file to it. Otherwise link
|
||||
// to the designer file
|
||||
if (File.Exists(dependent_name))
|
||||
{
|
||||
ps.WriteLine(" <DependentUpon>{0}</DependentUpon>", Path.GetFileName(dependent_name));
|
||||
}
|
||||
else
|
||||
{
|
||||
ps.WriteLine(" <AutoGen>True</AutoGen>");
|
||||
ps.WriteLine(" <DependentUpon>{0}</DependentUpon>", Path.GetFileName(filePath));
|
||||
}
|
||||
|
||||
ps.WriteLine(" </Compile>");
|
||||
}
|
||||
list.Add(autogen_name);
|
||||
}
|
||||
if (subType == SubType.Settings)
|
||||
{
|
||||
ps.Write(" <{0} ", project.Files.GetBuildAction(filePath));
|
||||
ps.WriteLine("Include=\"{0}\">", file);
|
||||
string fileName = Path.GetFileName(filePath);
|
||||
if (project.Files.GetBuildAction(filePath) == BuildAction.None)
|
||||
{
|
||||
ps.WriteLine(" <Generator>SettingsSingleFileGenerator</Generator>");
|
||||
ps.WriteLine(" <LastGenOutput>{0}</LastGenOutput>", fileName.Substring(0, fileName.LastIndexOf('.')) + ".Designer.cs");
|
||||
}
|
||||
else
|
||||
{
|
||||
ps.WriteLine(" <SubType>Code</SubType>");
|
||||
ps.WriteLine(" <AutoGen>True</AutoGen>");
|
||||
ps.WriteLine(" <DesignTimeSharedInput>True</DesignTimeSharedInput>");
|
||||
string fileNameShort = fileName.Substring(0, fileName.LastIndexOf('.'));
|
||||
string fileNameShorter = fileNameShort.Substring(0, fileNameShort.LastIndexOf('.'));
|
||||
ps.WriteLine(" <DependentUpon>{0}</DependentUpon>", Path.GetFileName(fileNameShorter + ".settings"));
|
||||
}
|
||||
ps.WriteLine(" </{0}>", project.Files.GetBuildAction(filePath));
|
||||
}
|
||||
else if (subType != SubType.Designer)
|
||||
{
|
||||
string path = Helper.NormalizePath(file);
|
||||
string path_lower = path.ToLower();
|
||||
|
||||
if (!list.Contains(filePath))
|
||||
{
|
||||
ps.Write(" <{0} ", project.Files.GetBuildAction(filePath));
|
||||
|
||||
int startPos = 0;
|
||||
if (project.Files.GetPreservePath(filePath))
|
||||
{
|
||||
while ((@"./\").IndexOf(file.Substring(startPos, 1)) != -1)
|
||||
startPos++;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
startPos = file.LastIndexOf(Path.GetFileName(path));
|
||||
}
|
||||
|
||||
// be sure to write out the path with backslashes so VS recognizes
|
||||
// the file properly.
|
||||
ps.WriteLine("Include=\"{0}\">", file);
|
||||
|
||||
int last_period_index = file.LastIndexOf('.');
|
||||
string short_file_name = (last_period_index >= 0)
|
||||
? file.Substring(0, last_period_index)
|
||||
: file;
|
||||
string extension = Path.GetExtension(path);
|
||||
// make this upper case, so that when File.Exists tests for the
|
||||
// existence of a designer file on a case-sensitive platform,
|
||||
// it is correctly identified.
|
||||
string designer_format = string.Format(".Designer{0}", extension);
|
||||
|
||||
if (path_lower.EndsWith(designer_format.ToLowerInvariant()))
|
||||
{
|
||||
int designer_index = path.IndexOf(designer_format);
|
||||
string file_name = path.Substring(0, designer_index);
|
||||
|
||||
// There are two corrections to the next lines:
|
||||
// 1. Fix the connection between a designer file and a form
|
||||
// or usercontrol that don't have an associated resx file.
|
||||
// 2. Connect settings files to associated designer files.
|
||||
if (File.Exists(file_name + extension))
|
||||
ps.WriteLine(" <DependentUpon>{0}</DependentUpon>", Path.GetFileName(file_name + extension));
|
||||
else if (File.Exists(file_name + ".resx"))
|
||||
ps.WriteLine(" <DependentUpon>{0}</DependentUpon>", Path.GetFileName(file_name + ".resx"));
|
||||
else if (File.Exists(file_name + ".settings"))
|
||||
{
|
||||
ps.WriteLine(" <DependentUpon>{0}</DependentUpon>", Path.GetFileName(file_name + ".settings"));
|
||||
ps.WriteLine(" <AutoGen>True</AutoGen>");
|
||||
ps.WriteLine(" <DesignTimeSharedInput>True</DesignTimeSharedInput>");
|
||||
}
|
||||
}
|
||||
else if (subType == SubType.CodeBehind)
|
||||
{
|
||||
ps.WriteLine(" <DependentUpon>{0}</DependentUpon>", Path.GetFileName(short_file_name));
|
||||
}
|
||||
if (project.Files.GetIsLink(filePath))
|
||||
{
|
||||
string alias = project.Files.GetLinkPath(filePath);
|
||||
alias += file.Substring(startPos);
|
||||
alias = Helper.NormalizePath(alias);
|
||||
ps.WriteLine(" <Link>{0}</Link>", alias);
|
||||
}
|
||||
else if (project.Files.GetBuildAction(filePath) != BuildAction.None)
|
||||
{
|
||||
if (project.Files.GetBuildAction(filePath) != BuildAction.EmbeddedResource)
|
||||
{
|
||||
ps.WriteLine(" <SubType>{0}</SubType>", subType);
|
||||
}
|
||||
}
|
||||
|
||||
if (project.Files.GetCopyToOutput(filePath) != CopyToOutput.Never)
|
||||
{
|
||||
ps.WriteLine(" <CopyToOutputDirectory>{0}</CopyToOutputDirectory>", project.Files.GetCopyToOutput(filePath));
|
||||
}
|
||||
|
||||
ps.WriteLine(" </{0}>", project.Files.GetBuildAction(filePath));
|
||||
}
|
||||
}
|
||||
}
|
||||
ps.WriteLine(" </ItemGroup>");
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(prebuild))
|
||||
{
|
||||
ps.WriteLine(" <Target Name=\"PreBuild\" BeforeTargets=\"PreBuildEvent\">");
|
||||
ps.WriteLine(" <Exec Command = \"{0}\" />", prebuild);
|
||||
ps.WriteLine(" </Target>");
|
||||
}
|
||||
if (!string.IsNullOrEmpty(postbuild))
|
||||
{
|
||||
ps.WriteLine(" <Target Name = \"PostBuild\" AfterTargets = \"PostBuildEvent\">");
|
||||
ps.WriteLine(" <Exec Command = \"{0}\" />", postbuild);
|
||||
ps.WriteLine(" </Target>");
|
||||
}
|
||||
|
||||
ps.WriteLine("</Project>");
|
||||
#endregion
|
||||
|
||||
@@ -790,6 +1011,7 @@ namespace Prebuild.Core.Targets
|
||||
foreach (ReferenceNode refr in otherReferences)
|
||||
{
|
||||
ps.Write(" <Reference");
|
||||
//ps.Write(" Update=\"");
|
||||
ps.Write(" Include=\"");
|
||||
ps.Write(refr.Name);
|
||||
ps.WriteLine("\" >");
|
||||
@@ -1166,6 +1388,9 @@ namespace Prebuild.Core.Targets
|
||||
|
||||
Helper.DeleteIfExists(projectFile);
|
||||
Helper.DeleteIfExists(userFile);
|
||||
|
||||
string projectobj = Helper.MakeFilePath(project.FullPath,"obj");
|
||||
Helper.DeleteFolderIfExists(projectobj);
|
||||
}
|
||||
|
||||
private void CleanSolution(SolutionNode solution)
|
||||
|
||||
@@ -63,6 +63,7 @@ namespace Prebuild.Core.Targets
|
||||
/// </summary>
|
||||
VS15,
|
||||
VS17,
|
||||
VS19
|
||||
VS19,
|
||||
VS22
|
||||
}
|
||||
}
|
||||
|
||||
@@ -232,6 +232,27 @@ namespace Prebuild.Core.Utilities
|
||||
return true;
|
||||
}
|
||||
|
||||
public static bool DeleteFolderIfExists(string file)
|
||||
{
|
||||
string resFile = null;
|
||||
try
|
||||
{
|
||||
resFile = ResolvePath(file);
|
||||
}
|
||||
catch (ArgumentException)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!Directory.Exists(resFile))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Directory.Delete(resFile, true);
|
||||
return true;
|
||||
}
|
||||
|
||||
static readonly char seperator = Path.DirectorySeparatorChar;
|
||||
|
||||
// This little gem was taken from the NeL source, thanks guys!
|
||||
|
||||
@@ -187,8 +187,8 @@
|
||||
<xs:all>
|
||||
<xs:element name="CompilerDefines" type="xs:string" minOccurs="0" />
|
||||
<xs:element name="OptimizeCode" type="xs:boolean" minOccurs="0" />
|
||||
<xs:element name="Prefer32Bit" type="xs:boolean" minOccurs="0" />
|
||||
<xs:element name="CheckUnderflowOverflow" type="xs:boolean" minOccurs="0" />
|
||||
<xs:element name="Prefer32Bit" type="xs:boolean" minOccurs="0" />
|
||||
<xs:element name="CheckUnderflowOverflow" type="xs:boolean" minOccurs="0" />
|
||||
<xs:element name="AllowUnsafe" type="xs:boolean" minOccurs="0" />
|
||||
<xs:element name="PreBuildEvent" type="xs:string" minOccurs="0" />
|
||||
<xs:element name="PostBuildEvent" type="xs:string" minOccurs="0" />
|
||||
@@ -214,6 +214,10 @@
|
||||
</xs:element>
|
||||
<xs:element name="WarningsAsErrors" type="xs:boolean" minOccurs="0" />
|
||||
<xs:element name="SuppressWarnings" type="xs:string" minOccurs="0" />
|
||||
<xs:element name="UseCommonOutputDirectory" type="xs:boolean" minOccurs="0" />
|
||||
<xs:element name="AppendTargetFrameworkToOutputPath" type="xs:boolean" minOccurs="0" />
|
||||
<xs:element name="AppendRuntimeIdentifierToOutputPath" type="xs:boolean" minOccurs="0" />
|
||||
<xs:element name="EnableDefaultItems" type="xs:boolean" minOccurs="0" />
|
||||
<xs:element name="OutputPath" type="xs:string" minOccurs="0" />
|
||||
<xs:element name="GenerateDocumentation" type="xs:boolean" minOccurs="0" />
|
||||
<xs:element name="XmlDocFile" type="xs:string" minOccurs="0" />
|
||||
|
||||
Reference in New Issue
Block a user