Skip to content

Commit

Permalink
Merge pull request dotnet#2 from Microsoft/xplat
Browse files Browse the repository at this point in the history
sync to latest
  • Loading branch information
XianghanWang authored Jan 13, 2017
2 parents be547a2 + 9654902 commit 8366e87
Show file tree
Hide file tree
Showing 312 changed files with 20,050 additions and 2,744 deletions.
19 changes: 0 additions & 19 deletions BootStrapMSBuild.proj

This file was deleted.

2 changes: 1 addition & 1 deletion BuildToolsVersion.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.0.26-prerelease-00826-05
1.0.27-prerelease-00927-05
2 changes: 1 addition & 1 deletion NuGet.Config
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<clear />
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
<add key="nuget.org v2" value="https://nuget.org/api/v2/" />
<!-- <add key="myget.org roslyn nightly" value="https://www.myget.org/F/roslyn-nightly/api/v3/index.json" /> -->
<add key="myget.org roslyn nightly" value="https://dotnet.myget.org/F/roslyn/api/v3/index.json" />
<add key="dotnet.myget.org buildtools v3" value="https://dotnet.myget.org/F/dotnet-buildtools/api/v3/index.json" />
<!-- <add key="myget.org nugetbuild" value="https://www.myget.org/F/nugetbuild/api/v3/index.json" /> -->
<add key="dotnet.myget.org dotnet-core v3" value="https://dotnet.myget.org/F/dotnet-core/api/v3/index.json" />
Expand Down
31 changes: 16 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,28 @@ The Microsoft Build Engine is a platform for building applications. This engine,
For more information on MSBuild, see the [MSDN documentation](https://msdn.microsoft.com/en-us/library/dd393574%28v=vs.140%29.aspx).

### Build Status
Full framework build from `master` (stable, inserted into Visual Studio builds):
[![Build Status](https://ci.dot.net/buildStatus/icon?job=Microsoft_msbuild/master/innerloop_master_Windows_NT_Desktop)](https://ci.dot.net/job/Microsoft_msbuild/job/master/job/innerloop_master_Windows_NT_Desktop)

The `xplat` branch is soon to be merged back upstream. Follow the [The Great Merge](https://github.com/Microsoft/msbuild/milestone/6) milestone for progress.
The current development branch is `xplat`. It builds for .NET Core and the full desktop .NET framework.

| Runtime\OS | Windows | Ubuntu 14.04 | Ubuntu 16.04 |Mac OS X|
|:------|:------:|:------:|:------:|:------:|
| **Full Framework** |[![Build Status](https://ci.dot.net/buildStatus/icon?job=Microsoft_msbuild/master/innerloop_xplat_Windows_NT_Desktop)](https://ci.dot.net/job/Microsoft_msbuild/job/master/job/innerloop_xplat_Windows_NT_Desktop)| N/A | N/A | N/A |
|**.NET Core**|[![Build Status](https://ci.dot.net/buildStatus/icon?job=Microsoft_msbuild/master/innerloop_xplat_Windows_NT_CoreCLR)](https://ci.dot.net/job/Microsoft_msbuild/job/master/job/innerloop_xplat_Windows_NT_CoreCLR)|[![Build Status](https://ci.dot.net/buildStatus/icon?job=Microsoft_msbuild/master/innerloop_xplat_Ubuntu14.04_CoreCLR)](https://ci.dot.net/job/Microsoft_msbuild/job/master/job/innerloop_xplat_Ubuntu14.04_CoreCLR)|[![Build Status](https://ci.dot.net/buildStatus/icon?job=Microsoft_msbuild/master/innerloop_xplat_Ubuntu16.04_CoreCLR)](https://ci.dot.net/job/Microsoft_msbuild/job/master/job/innerloop_xplat_Ubuntu16.04_CoreCLR)|[![Build Status](https://ci.dot.net/buildStatus/icon?job=Microsoft_msbuild/master/innerloop_xplat_OSX_CoreCLR)](https://ci.dot.net/job/Microsoft_msbuild/job/master/job/innerloop_xplat_OSX_CoreCLR)|
| **Full Framework** |[![Build Status](https://ci2.dot.net/buildStatus/icon?job=Microsoft_msbuild/master/innerloop_xplat_Windows_NT_Desktop)](https://ci2.dot.net/job/Microsoft_msbuild/job/master/job/innerloop_xplat_Windows_NT_Desktop)| N/A | N/A | N/A |
|**.NET Core**|[![Build Status](https://ci2.dot.net/buildStatus/icon?job=Microsoft_msbuild/master/innerloop_xplat_Windows_NT_CoreCLR)](https://ci2.dot.net/job/Microsoft_msbuild/job/master/job/innerloop_xplat_Windows_NT_CoreCLR)|[![Build Status](https://ci2.dot.net/buildStatus/icon?job=Microsoft_msbuild/master/innerloop_xplat_Ubuntu14.04_CoreCLR)](https://ci2.dot.net/job/Microsoft_msbuild/job/master/job/innerloop_xplat_Ubuntu14.04_CoreCLR)|[![Build Status](https://ci2.dot.net/buildStatus/icon?job=Microsoft_msbuild/master/innerloop_xplat_Ubuntu16.04_CoreCLR)](https://ci2.dot.net/job/Microsoft_msbuild/job/master/job/innerloop_xplat_Ubuntu16.04_CoreCLR)|[![Build Status](https://ci2.dot.net/buildStatus/icon?job=Microsoft_msbuild/master/innerloop_xplat_OSX_CoreCLR)](https://ci2.dot.net/job/Microsoft_msbuild/job/master/job/innerloop_xplat_OSX_CoreCLR)|
|**Mono**|[![Build Status](https://ci2.dot.net/buildStatus/icon?job=Microsoft_msbuild/master/innerloop_xplat_Windows_NT_Mono)](https://ci2.dot.net/job/Microsoft_msbuild/job/master/job/innerloop_xplat_Windows_NT_Mono)|[![Build Status](https://ci2.dot.net/buildStatus/icon?job=Microsoft_msbuild/master/innerloop_xplat_Ubuntu14.04_Mono)](https://ci2.dot.net/job/Microsoft_msbuild/job/master/job/innerloop_xplat_Ubuntu14.04_Mono)|[![Build Status](https://ci2.dot.net/buildStatus/icon?job=Microsoft_msbuild/master/innerloop_xplat_Ubuntu16.04_Mono)](https://ci2.dot.net/job/Microsoft_msbuild/job/master/job/innerloop_xplat_Ubuntu16.04_Mono)|[![Build Status](https://ci2.dot.net/buildStatus/icon?job=Microsoft_msbuild/master/innerloop_xplat_OSX_Mono)](https://ci2.dot.net/job/Microsoft_msbuild/job/master/job/innerloop_xplat_OSX_Mono)|

Full-framework-only build from `master` (deprecated):
[![Build Status](https://ci2.dot.net/buildStatus/icon?job=Microsoft_msbuild/master/innerloop_master_Windows_NT_Desktop)](https://ci2.dot.net/job/Microsoft_msbuild/job/master/job/innerloop_master_Windows_NT_Desktop)


[![Join the chat at https://gitter.im/Microsoft/msbuild](https://badges.gitter.im/Microsoft/msbuild.svg)](https://gitter.im/Microsoft/msbuild?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
[![Check out what we're working on using our Waffle board!](https://badge.waffle.io/Microsoft/msbuild.svg?label=In+Progress&title=waffle+board)](http://waffle.io/Microsoft/msbuild)

### Source code

* Clone the sources: `git clone https://github.com/Microsoft/msbuild.git`

### Building
## Building MSBuild in VS 2015
For the full supported experience, you will need to have Visual Studio 2015. You can open the solution in Visual Studio 2013, but you will encounter issues building with the provided scripts.
## Building
### Building MSBuild with VS 2015
For the full supported experience, you will need to have Visual Studio 2015. You can open the solution in Visual Studio 2017 RC, but you will encounter issues building with the provided scripts.

To get started on **Visual Studio 2015**:

Expand All @@ -32,10 +34,10 @@ To get started on **Visual Studio 2015**:
- _Universal Windows App Development Tools_
- _Tools and Windows SDK 10.0.10240_
2. Clone the source code (see above).
3. Restore NuGet packages: `msbuild /t:BulkRestoreNugetPackages build.proj`
4. Open src/MSBuild.sln solution in Visual Studio 2015.
3. Build the code using the `cibuild.cmd` script.
5. Open src/MSBuild.sln solution in Visual Studio 2015.

## Building MSBuild in Unix (Mac & Linux)
### Building MSBuild in Unix (Mac & Linux)
MSBuild's xplat branch allows MSBuild to be run on Unix Systems. Set-up instructions can be viewed on the wiki: [Building Testing and Debugging on .Net Core MSBuild](https://github.com/Microsoft/msbuild/wiki/Building-Testing-and-Debugging-on-.Net-Core-MSBuild)

## Localization
Expand All @@ -44,14 +46,13 @@ You can turn on localized builds via the `/p:LocalizedBuild=true` command line a
### How to Engage, Contribute and Provide Feedback
This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.

#### Getting Started
Before you contribute, please read through the contributing and developer guides to get an idea of what kinds of pull requests we will or won't accept.

* [Contributing Guide](https://github.com/Microsoft/msbuild/wiki/Contributing-Code)
* [Developer Guide](https://github.com/Microsoft/msbuild/wiki/Building-Testing-and-Debugging)

Want to get more familiar with what's going on in the code?
* [Pull requests](https://github.com/Microsoft/msbuild/pulls): [Open](https://github.com/Microsoft/msbuild/pulls?q=is%3Aopen+is%3Apr)/[Closed](https://github.com/Microsoft/msbuild/pulls?q=is%3Apr+is%3Aclosed)
* [Issues](https://github.com/Microsoft/msbuild/issues)
Looking for something to work on? This list of [up for grabs issues](https://github.com/Microsoft/msbuild/issues?q=is%3Aopen+is%3Aissue+label%3Aup-for-grabs) is a great place to start.

You are also encouraged to start a discussion by filing an issue or creating a gist.

Expand Down
4 changes: 2 additions & 2 deletions RebuildWithLocalMSBuild.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ if %ERRORLEVEL% NEQ 0 (
taskkill /F /IM vbcscompiler.exe

set MSBUILDLOGPATH=%~dp0msbuild_move_bootstrap.log
set MSBUILD_ARGS=/verbosity:minimal BootStrapMSbuild.proj /p:Configuration=Debug-NetCore
set MSBUILD_ARGS=/verbosity:minimal targets\BootStrapMSbuild.proj /p:Configuration=Debug-NetCore

echo.
echo ** Moving bootstrapped MSBuild to the bootstrap folder
Expand All @@ -41,7 +41,7 @@ call "%~dp0build.cmd"
set MSBUILD_ARGS=

if %ERRORLEVEL% NEQ 0 (
echo.
echo.
echo build.cmd with bootstrapped MSBuild failed with errorlevel %ERRORLEVEL% 1>&2
goto :error
)
Expand Down
2 changes: 1 addition & 1 deletion Samples/Dependency/Dependency.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<Compile Include="Alpha.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<ItemGroup Condition="'$(NetCoreBuild)' != 'true'">
<Reference Include="System" />
</ItemGroup>
<Import Project="..\dir.targets" />
Expand Down
93 changes: 93 additions & 0 deletions build/LocalizationTasks/ConvertToNeutralXlf.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
using System.IO;
using System.Linq;
using System.Xml.Linq;
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;

namespace Microsoft.Build.LocalizationTasks
{
public class ConvertToNeutralXlf : Task
{
/// <summary>
/// Path to the neutral resx files to generate a corresponding neutral xlf from.
/// </summary>
[Required]
public ITaskItem[] NeutralResources { get; set; }

public override bool Execute()
{
if (NeutralResources.Length == 0)
{
Log.LogError($"Task was called with empty {nameof(NeutralResources)}");
}

foreach (var neutralResource in NeutralResources)
{
var localizedXlf = LocalizationUtils.LocalizedXlfFiles(neutralResource).FirstOrDefault();

if (localizedXlf == null)
{
Log.LogError($"{neutralResource} has no corresponding xlf files");
}

var outputFilename = ComputeNeutralXlfName(neutralResource);

MakeNeutral(localizedXlf, outputFilename);
}

return !Log.HasLoggedErrors;
}

private string ComputeNeutralXlfName(ITaskItem neutralResouce)
{
var filename = neutralResouce.GetMetadata("Filename");
var xlfRootPath = LocalizationUtils.ComputeXlfRootPath(neutralResouce);

return Path.Combine(xlfRootPath, filename + ".xlf");
}

private static void MakeNeutral(string inputfilename, string outputfilename)
{
//need to load xml file
var doc = XDocument.Load(inputfilename);

//step 1: remove target-language attribute
//< file datatype = "xml" source - language = "en" target - language = "cs" original = "../Strings.shared.resx" >
var fileNodes = from node in doc.Descendants()
where node.Name.LocalName != null && node.Name.LocalName == "file"
select node;
fileNodes.ToList().ForEach(x =>
{
if (x.HasAttributes)
{
foreach (var attrib in x.Attributes())
{
if (attrib.Name == "target-language")
attrib.Remove();
}
}
});

//step 2: remove all tags with "target"
// < target state = "new" > MSBuild is expecting a valid "{0}" object.</ target >
var targetNodes = from node in doc.Descendants()
where node.Name.LocalName != null && node.Name.LocalName == "target"
select node;
targetNodes.ToList().ForEach(x => x.Remove());

//save
var fi = new FileInfo(outputfilename);

if (fi.Exists)
{
fi.Delete();
}
if (fi.Directory.Exists == false)
{
fi.Directory.Create();
}

doc.Save(fi.FullName);
}
}
}
25 changes: 3 additions & 22 deletions build/LocalizationTasks/EmitLocalizedResources.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,6 @@ public class EmitLocalizedResources : Task
[Required]
public string LocalizedResxRoot { get; set; }

/// <summary>
/// Path to the root directory that contains the xlf files for a neutral resource
/// Assumes all neutral resource have the same relative path to their xlf
/// </summary>
[Required]
public string RelativePathToXlfRoot { get; set; }

[Output]
public ITaskItem[] ResolvedXlfResources { get; set; }

Expand Down Expand Up @@ -78,29 +71,17 @@ private ITaskItem ComputeLocalizedResource(ITaskItem xlf)

private IEnumerable<ITaskItem> ComputeXlfResourceItems(ITaskItem neutralResource)
{
var neutralResxRootDirectory = Path.GetDirectoryName(neutralResource.GetMetadata("FullPath"));
var xlfRootPath = Path.Combine(neutralResxRootDirectory, RelativePathToXlfRoot);
string xlfRootPath = LocalizationUtils.ComputeXlfRootPath(neutralResource);

if (!Directory.Exists(xlfRootPath))
{
throw new InvalidOperationException(
$"Could not find expected xlf root {xlfRootPath} next to its neutral resource {neutralResource.ItemSpec}");
}

var resx = neutralResource.ItemSpec;

return
(Directory.EnumerateFiles(xlfRootPath)
.Where(f => IsValidXlf(f, resx))
.Select((f => CreateXLFTaskItemForNeutralResx(f, resx))));
}

private bool IsValidXlf(string xlfPath, string resx)
{
var resxFileName = Path.GetFileNameWithoutExtension(resx);
var xlfFileName = Path.GetFileName(xlfPath);

return Regex.IsMatch(xlfFileName, $"^{resxFileName}\\.[a-zA-Z\\-]+\\.xlf$");
LocalizationUtils.LocalizedXlfFiles(neutralResource)
.Select(f => CreateXLFTaskItemForNeutralResx(f, neutralResource.ItemSpec));
}

private ITaskItem CreateXLFTaskItemForNeutralResx(string xlfPath, string neutralResx)
Expand Down
44 changes: 44 additions & 0 deletions build/LocalizationTasks/LocalizationUtils.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;

namespace Microsoft.Build.LocalizationTasks
{
public static class LocalizationUtils
{
/// <summary>
/// Path to the root directory that contains the xlf files for a neutral resource
/// Assumes all neutral resource have the same relative path to their xlf
/// </summary>
public static string RelativePathToXlfRoot = "xlf";

public static string ComputeXlfRootPath(ITaskItem neutralResource)
{
var neutralResxRootDirectory = Path.GetDirectoryName(neutralResource.GetMetadata("FullPath"));
return Path.Combine(neutralResxRootDirectory, RelativePathToXlfRoot);
}

public static bool IsValidLocalizedXlfName(string xlfPath, string neutralResx)
{
var resxFileName = Path.GetFileNameWithoutExtension(neutralResx);
var xlfFileName = Path.GetFileName(xlfPath);

return Regex.IsMatch(xlfFileName, $"^{resxFileName}\\.[a-zA-Z\\-]+\\.xlf$");
}

public static IEnumerable<string> LocalizedXlfFiles(string xlfRootPath, string neutralResx)
{
return Directory.EnumerateFiles(xlfRootPath)
.Where(f => IsValidLocalizedXlfName(f, neutralResx));
}

public static IEnumerable<string> LocalizedXlfFiles(ITaskItem neutralResouce)
{
return LocalizedXlfFiles(ComputeXlfRootPath(neutralResouce), neutralResouce.ItemSpec);
}
}
}
18 changes: 8 additions & 10 deletions build/LocalizationTasks/Microsoft.Build.LocalizationTasks.csproj
Original file line number Diff line number Diff line change
@@ -1,27 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />

<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<OutputType>Library</OutputType>
<RootNamespace>Microsoft.Build.LocalizationTasks</RootNamespace>
<AssemblyName>Microsoft.Build.LocalizationTasks</AssemblyName>
<ProjectGuid>{06347A6C-32A4-4218-A930-0A22699C726C}</ProjectGuid>
</PropertyGroup>

<ItemGroup>
<!-- Source Files -->
<Compile Include="*.cs"/>
<Compile Include="*.cs" />
</ItemGroup>

<ItemGroup>
<Reference Include="System"/>
<Reference Include="System.Text.RegularExpressions"/>
<Reference Include="System" />
<Reference Include="System.Text.RegularExpressions" />
<Reference Include="Microsoft.Build.Framework, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<Reference Include="Microsoft.Build.Utilities.Core, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<Reference Include="System.Xml" />
<Reference Include="System.Xml.Linq" />
</ItemGroup>

<Import Project="..\dir.targets" />

</Project>
</Project>
Loading

0 comments on commit 8366e87

Please sign in to comment.