提交 41e0b780 编写于 作者: D David Denis 提交者: Ryland Alaniz

Enable the building of WinForms and WPF projects from Unix

上级 333565f2
......@@ -50,7 +50,7 @@ internal sealed class MarkupCompiler
public string TargetPath
{
get { return _targetPath; }
set { _targetPath = value; }
set { _targetPath = value;}
}
/// <summary>
......@@ -480,14 +480,14 @@ private void Initialize(FileUnit sourceFile)
// Prime the output directory
if (TargetPath.Length > 0)
{
// check for ending '\'
if (!TargetPath.EndsWith(ESCAPED_BACKSLASH, StringComparison.Ordinal))
// check for ending Path.DirectorySeparatorChar
if (!TargetPath.EndsWith(string.Empty + Path.DirectorySeparatorChar, StringComparison.Ordinal))
{
TargetPath += ESCAPED_BACKSLASH;
TargetPath += Path.DirectorySeparatorChar;
}
}
int pathEndIndex = SourceFileInfo.RelativeSourceFilePath.LastIndexOf(ESCAPED_BACKSLASH, StringComparison.Ordinal);
int pathEndIndex = SourceFileInfo.RelativeSourceFilePath.LastIndexOf(string.Empty + Path.DirectorySeparatorChar, StringComparison.Ordinal);
string targetPath = TargetPath + SourceFileInfo.RelativeSourceFilePath.Substring(0, pathEndIndex + 1);
// Create if not already exists
......@@ -712,7 +712,7 @@ private SourceFileInfo OnSourceFileResolve(FileUnit file)
if (sourceFileInfo.IsXamlFile)
{
int fileExtIndex = file.Path.LastIndexOf(DOT, StringComparison.Ordinal);
sourceFileInfo.RelativeSourceFilePath = file.Path.Substring(0, fileExtIndex);
}
}
......@@ -1580,7 +1580,7 @@ private string ParentFolderPrefix
{
string relPath = TargetPath.Substring(SourceFileInfo.SourcePath.Length);
relPath += SourceFileInfo.RelativeSourceFilePath;
string[] dirs = relPath.Split(new Char[] { ESCAPED_BACKSLASH_CHAR });
string[] dirs = relPath.Split(new Char[] { Path.DirectorySeparatorChar });
for (int i = 1; i < dirs.Length; i++)
{
parentFolderPrefix += PARENTFOLDER;
......@@ -3545,8 +3545,6 @@ internal string SubClass
private const string VER = "V";
private const string COMPONENT = "component";
private const char COMPONENT_DELIMITER = ';';
private const string ESCAPED_BACKSLASH = "\\";
private const char ESCAPED_BACKSLASH_CHAR = '\\';
private const string FORWARDSLASH = "/";
private const string URISCHEME_PACK = "pack";
private const string PARENTFOLDER = @"..\";
......
......@@ -40,7 +40,7 @@ internal class CompilerWrapper : MarshalByRefObject
internal CompilerWrapper()
{
_mc = new MarkupCompiler();
_sourceDir = Directory.GetCurrentDirectory() + "\\";
_sourceDir = Directory.GetCurrentDirectory() + Path.DirectorySeparatorChar;
_nErrors = 0;
}
......@@ -408,7 +408,7 @@ private string GetResolvedFilePath(string filePath, ref string newSourceDir)
// and put the deepest directory that file is in as the new
// SourceDir.
//
int pathEndIndex = fullFilePath.LastIndexOf("\\", StringComparison.Ordinal);
int pathEndIndex = fullFilePath.LastIndexOf(string.Empty + Path.DirectorySeparatorChar, StringComparison.Ordinal);
newSourceDir = fullFilePath.Substring(0, pathEndIndex + 1);
newRelativeFilePath = fullFilePath.Substring(pathEndIndex + 1);
......
......@@ -488,7 +488,7 @@ private void RecompileContentFiles()
{
if (ListIsNotEmpty(_mcPass1.ContentFiles))
{
string curDir = Directory.GetCurrentDirectory() + "\\";
string curDir = Directory.GetCurrentDirectory() + Path.DirectorySeparatorChar;
int count = _mcPass1.ContentFiles.Length;
......
......@@ -73,14 +73,13 @@ internal static void DisplayLogo(TaskLoggingHelper log, string taskName)
internal static string CreateFullFilePath(string thePath, string rootPath)
{
// make it an absolute path if not already so
if ( !Path.IsPathRooted(thePath) )
if (!Path.IsPathRooted(thePath) )
{
thePath = rootPath + thePath;
}
// get rid of '..' and '.' if any
thePath = Path.GetFullPath(thePath);
return thePath;
}
......@@ -100,7 +99,7 @@ internal static string GetRootRelativePath(string path1, string path2)
string fullpath1;
string fullpath2;
string sourceDir = Directory.GetCurrentDirectory() + "\\";
string sourceDir = Directory.GetCurrentDirectory() + Path.DirectorySeparatorChar;
// make sure path1 and Path2 are both full path
// so that they can be compared on right base.
......
......@@ -74,7 +74,7 @@ public sealed class MarkupCompilePass1 : Task
public MarkupCompilePass1( ) : base(SR.SharedResourceManager)
{
// set the source directory
_sourceDir = Directory.GetCurrentDirectory() + "\\";
_sourceDir = Directory.GetCurrentDirectory() + Path.DirectorySeparatorChar;
_outputType = SharedStrings.WinExe;
......@@ -276,10 +276,10 @@ public string OutputPath
// Get the relative path based on sourceDir
_outputDir= TaskHelper.CreateFullFilePath(filePath, SourceDir);
// Make sure OutputDir always ends with '\\'.
if (!_outputDir.EndsWith("\\", StringComparison.Ordinal))
// Make sure OutputDir always ends with Path.DirectorySeparatorChar
if (!_outputDir.EndsWith(string.Empty + Path.DirectorySeparatorChar, StringComparison.Ordinal))
{
_outputDir += "\\";
_outputDir += Path.DirectorySeparatorChar;
}
}
}
......@@ -1080,8 +1080,8 @@ private string GetResolvedFilePath(string filePath, ref string newSourceDir)
// and put the deepest directory that file is in as the new
// SourceDir.
//
int pathEndIndex = fullFilePath.LastIndexOf("\\", StringComparison.Ordinal);
int pathEndIndex = fullFilePath.LastIndexOf(string.Empty + Path.DirectorySeparatorChar, StringComparison.Ordinal);
newSourceDir = fullFilePath.Substring(0, pathEndIndex + 1);
newRelativeFilePath = TaskHelper.GetRootRelativePath(newSourceDir, fullFilePath);
}
......@@ -1466,7 +1466,7 @@ private void GenerateOutputItems( )
codeItem = new TaskItem();
codeItem.ItemSpec = genLangFilePath;
outputCodeFileList.Add(codeItem);
Log.LogMessageFromResources(MessageImportance.Low, SRID.GeneratedCodeFile, codeItem.ItemSpec);
......
......@@ -43,7 +43,6 @@ namespace Microsoft.Build.Tasks.Windows
/// </summary>
public sealed class MarkupCompilePass2 : Task
{
//------------------------------------------------------
//
// Constructors
......@@ -58,7 +57,7 @@ public sealed class MarkupCompilePass2 : Task
public MarkupCompilePass2( ) : base(SR.SharedResourceManager)
{
// set the source directory
_sourceDir = Directory.GetCurrentDirectory() + "\\";
_sourceDir = Directory.GetCurrentDirectory() + Path.DirectorySeparatorChar;
_outputType = SharedStrings.WinExe;
......@@ -253,10 +252,10 @@ public string OutputPath
// Get the relative path based on sourceDir
_outputPath= TaskHelper.CreateFullFilePath(filePath, SourceDir);
// Make sure OutputDir always ends with '\\'.
if (!_outputPath.EndsWith("\\", StringComparison.Ordinal))
// Make sure OutputDir always ends with Path.DirectorySeparatorChar
if (!_outputPath.EndsWith(string.Empty + Path.DirectorySeparatorChar, StringComparison.Ordinal))
{
_outputPath += "\\";
_outputPath += Path.DirectorySeparatorChar;
}
}
}
......@@ -546,7 +545,7 @@ private string GetResolvedFilePath(string filePath, ref string newSourceDir)
// and put the deepest directory that file is in as the new
// SourceDir.
//
int pathEndIndex = fullFilePath.LastIndexOf("\\", StringComparison.Ordinal);
int pathEndIndex = fullFilePath.LastIndexOf(string.Empty + Path.DirectorySeparatorChar, StringComparison.Ordinal);
newSourceDir = fullFilePath.Substring(0, pathEndIndex + 1);
newRelativeFilePath = TaskHelper.GetRootRelativePath(newSourceDir, fullFilePath);
......
......@@ -80,7 +80,7 @@
<ItemGroup>
<Compile Include="SR.cs" />
<Compile Include="$(WpfCommonDir)src\System\SR.cs">
<Compile Include="$(WpfCommonDir)src\System\SR.cs" >
<Link>Common\System\SR.cs</Link>
</Compile>
......
......@@ -457,7 +457,7 @@ private static Assembly LoadAssemblyHelper(string assemblyGivenName, string asse
{
// assemblyPath is set, Load the assembly from this specified place.
// the path must be full file path which contains directory, file name and extension.
Debug.Assert(!assemblyPath.EndsWith("\\", StringComparison.Ordinal), "the assembly path should be a full file path containing file extension");
Debug.Assert(!assemblyPath.EndsWith(string.Empty + Path.DirectorySeparatorChar, StringComparison.Ordinal), "the assembly path should be a full file path containing file extension");
// LoadFile will only override your request only if it is in the GAC
retassem = Assembly.LoadFile(assemblyPath);
......
......@@ -44,7 +44,7 @@ static internal class ContainerUtilities
/// Used by ConvertBackSlashPathToStringArrayPath and
/// ConvertStringArrayPathToBackSlashPath to separate path elements.
static readonly internal char PathSeparator = '\\';
static readonly internal char PathSeparator = Path.DirectorySeparatorChar;
static private readonly char[] _PathSeparatorArray = new char[] { PathSeparator };
static readonly internal string PathSeparatorAsString = new string(ContainerUtilities.PathSeparator, 1);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册