Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 69 additions & 0 deletions MSBuild.sln
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Samples", "Samples", "{760FF85D-8BEB-4992-8095-A9678F88FD47}"
ProjectSection(SolutionItems) = preProject
src\Samples\Directory.Build.props = src\Samples\Directory.Build.props
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Build", "src\Build\Microsoft.Build.csproj", "{69BE05E2-CBDA-4D27-9733-44E12B0F5627}"
EndProject
Expand Down Expand Up @@ -69,6 +72,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NuGet.MSBuildSdkResolver.Un
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MSBuild.Bootstrap", "src\MSBuild.Bootstrap\MSBuild.Bootstrap.csproj", "{CEAEE4FE-9298-443B-AFC5-0F72472484B6}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RoslynCodeTaskFactory", "src\Samples\RoslynCodeTaskFactory\RoslynCodeTaskFactory.csproj", "{46827763-0A5F-47E1-9D6F-9D4BD22883C7}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DownloadFile", "src\Samples\DownloadFile\DownloadFile.csproj", "{5C356475-B9A6-4CA5-A6BD-0B17FE3FEFC4}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -898,6 +905,66 @@ Global
{CEAEE4FE-9298-443B-AFC5-0F72472484B6}.Release-MONO|x64.Build.0 = Release-MONO|x64
{CEAEE4FE-9298-443B-AFC5-0F72472484B6}.Release-MONO|x86.ActiveCfg = Release-MONO|Any CPU
{CEAEE4FE-9298-443B-AFC5-0F72472484B6}.Release-MONO|x86.Build.0 = Release-MONO|Any CPU
{46827763-0A5F-47E1-9D6F-9D4BD22883C7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{46827763-0A5F-47E1-9D6F-9D4BD22883C7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{46827763-0A5F-47E1-9D6F-9D4BD22883C7}.Debug|x64.ActiveCfg = Debug|x64
{46827763-0A5F-47E1-9D6F-9D4BD22883C7}.Debug|x64.Build.0 = Debug|x64
{46827763-0A5F-47E1-9D6F-9D4BD22883C7}.Debug|x86.ActiveCfg = Debug|Any CPU
{46827763-0A5F-47E1-9D6F-9D4BD22883C7}.Debug|x86.Build.0 = Debug|Any CPU
{46827763-0A5F-47E1-9D6F-9D4BD22883C7}.Debug-MONO|Any CPU.ActiveCfg = Debug-MONO|Any CPU
{46827763-0A5F-47E1-9D6F-9D4BD22883C7}.Debug-MONO|Any CPU.Build.0 = Debug-MONO|Any CPU
{46827763-0A5F-47E1-9D6F-9D4BD22883C7}.Debug-MONO|x64.ActiveCfg = Debug-MONO|x64
{46827763-0A5F-47E1-9D6F-9D4BD22883C7}.Debug-MONO|x64.Build.0 = Debug-MONO|x64
{46827763-0A5F-47E1-9D6F-9D4BD22883C7}.Debug-MONO|x86.ActiveCfg = Debug-MONO|Any CPU
{46827763-0A5F-47E1-9D6F-9D4BD22883C7}.Debug-MONO|x86.Build.0 = Debug-MONO|Any CPU
{46827763-0A5F-47E1-9D6F-9D4BD22883C7}.MachineIndependent|Any CPU.ActiveCfg = Release-MONO|Any CPU
{46827763-0A5F-47E1-9D6F-9D4BD22883C7}.MachineIndependent|Any CPU.Build.0 = Release-MONO|Any CPU
{46827763-0A5F-47E1-9D6F-9D4BD22883C7}.MachineIndependent|x64.ActiveCfg = Release|x64
{46827763-0A5F-47E1-9D6F-9D4BD22883C7}.MachineIndependent|x64.Build.0 = Release|x64
{46827763-0A5F-47E1-9D6F-9D4BD22883C7}.MachineIndependent|x86.ActiveCfg = Release-MONO|Any CPU
{46827763-0A5F-47E1-9D6F-9D4BD22883C7}.MachineIndependent|x86.Build.0 = Release-MONO|Any CPU
{46827763-0A5F-47E1-9D6F-9D4BD22883C7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{46827763-0A5F-47E1-9D6F-9D4BD22883C7}.Release|Any CPU.Build.0 = Release|Any CPU
{46827763-0A5F-47E1-9D6F-9D4BD22883C7}.Release|x64.ActiveCfg = Release|x64
{46827763-0A5F-47E1-9D6F-9D4BD22883C7}.Release|x64.Build.0 = Release|x64
{46827763-0A5F-47E1-9D6F-9D4BD22883C7}.Release|x86.ActiveCfg = Release|Any CPU
{46827763-0A5F-47E1-9D6F-9D4BD22883C7}.Release|x86.Build.0 = Release|Any CPU
{46827763-0A5F-47E1-9D6F-9D4BD22883C7}.Release-MONO|Any CPU.ActiveCfg = Release-MONO|Any CPU
{46827763-0A5F-47E1-9D6F-9D4BD22883C7}.Release-MONO|Any CPU.Build.0 = Release-MONO|Any CPU
{46827763-0A5F-47E1-9D6F-9D4BD22883C7}.Release-MONO|x64.ActiveCfg = Release-MONO|x64
{46827763-0A5F-47E1-9D6F-9D4BD22883C7}.Release-MONO|x64.Build.0 = Release-MONO|x64
{46827763-0A5F-47E1-9D6F-9D4BD22883C7}.Release-MONO|x86.ActiveCfg = Release-MONO|Any CPU
{46827763-0A5F-47E1-9D6F-9D4BD22883C7}.Release-MONO|x86.Build.0 = Release-MONO|Any CPU
{5C356475-B9A6-4CA5-A6BD-0B17FE3FEFC4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5C356475-B9A6-4CA5-A6BD-0B17FE3FEFC4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5C356475-B9A6-4CA5-A6BD-0B17FE3FEFC4}.Debug|x64.ActiveCfg = Debug|x64
{5C356475-B9A6-4CA5-A6BD-0B17FE3FEFC4}.Debug|x64.Build.0 = Debug|x64
{5C356475-B9A6-4CA5-A6BD-0B17FE3FEFC4}.Debug|x86.ActiveCfg = Debug|Any CPU
{5C356475-B9A6-4CA5-A6BD-0B17FE3FEFC4}.Debug|x86.Build.0 = Debug|Any CPU
{5C356475-B9A6-4CA5-A6BD-0B17FE3FEFC4}.Debug-MONO|Any CPU.ActiveCfg = Debug-MONO|Any CPU
{5C356475-B9A6-4CA5-A6BD-0B17FE3FEFC4}.Debug-MONO|Any CPU.Build.0 = Debug-MONO|Any CPU
{5C356475-B9A6-4CA5-A6BD-0B17FE3FEFC4}.Debug-MONO|x64.ActiveCfg = Debug-MONO|x64
{5C356475-B9A6-4CA5-A6BD-0B17FE3FEFC4}.Debug-MONO|x64.Build.0 = Debug-MONO|x64
{5C356475-B9A6-4CA5-A6BD-0B17FE3FEFC4}.Debug-MONO|x86.ActiveCfg = Debug-MONO|Any CPU
{5C356475-B9A6-4CA5-A6BD-0B17FE3FEFC4}.Debug-MONO|x86.Build.0 = Debug-MONO|Any CPU
{5C356475-B9A6-4CA5-A6BD-0B17FE3FEFC4}.MachineIndependent|Any CPU.ActiveCfg = Release-MONO|Any CPU
{5C356475-B9A6-4CA5-A6BD-0B17FE3FEFC4}.MachineIndependent|Any CPU.Build.0 = Release-MONO|Any CPU
{5C356475-B9A6-4CA5-A6BD-0B17FE3FEFC4}.MachineIndependent|x64.ActiveCfg = Release|x64
{5C356475-B9A6-4CA5-A6BD-0B17FE3FEFC4}.MachineIndependent|x64.Build.0 = Release|x64
{5C356475-B9A6-4CA5-A6BD-0B17FE3FEFC4}.MachineIndependent|x86.ActiveCfg = Release-MONO|Any CPU
{5C356475-B9A6-4CA5-A6BD-0B17FE3FEFC4}.MachineIndependent|x86.Build.0 = Release-MONO|Any CPU
{5C356475-B9A6-4CA5-A6BD-0B17FE3FEFC4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5C356475-B9A6-4CA5-A6BD-0B17FE3FEFC4}.Release|Any CPU.Build.0 = Release|Any CPU
{5C356475-B9A6-4CA5-A6BD-0B17FE3FEFC4}.Release|x64.ActiveCfg = Release|x64
{5C356475-B9A6-4CA5-A6BD-0B17FE3FEFC4}.Release|x64.Build.0 = Release|x64
{5C356475-B9A6-4CA5-A6BD-0B17FE3FEFC4}.Release|x86.ActiveCfg = Release|Any CPU
{5C356475-B9A6-4CA5-A6BD-0B17FE3FEFC4}.Release|x86.Build.0 = Release|Any CPU
{5C356475-B9A6-4CA5-A6BD-0B17FE3FEFC4}.Release-MONO|Any CPU.ActiveCfg = Release-MONO|Any CPU
{5C356475-B9A6-4CA5-A6BD-0B17FE3FEFC4}.Release-MONO|Any CPU.Build.0 = Release-MONO|Any CPU
{5C356475-B9A6-4CA5-A6BD-0B17FE3FEFC4}.Release-MONO|x64.ActiveCfg = Release-MONO|x64
{5C356475-B9A6-4CA5-A6BD-0B17FE3FEFC4}.Release-MONO|x64.Build.0 = Release-MONO|x64
{5C356475-B9A6-4CA5-A6BD-0B17FE3FEFC4}.Release-MONO|x86.ActiveCfg = Release-MONO|Any CPU
{5C356475-B9A6-4CA5-A6BD-0B17FE3FEFC4}.Release-MONO|x86.Build.0 = Release-MONO|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -914,6 +981,8 @@ Global
{16DBDF17-3E0E-4140-989A-B42638126A40} = {9BAD9352-DEFB-45E5-B8A4-4816B9B22A33}
{EDBFE32E-F264-4F01-97C3-B58F8B9165C9} = {9BAD9352-DEFB-45E5-B8A4-4816B9B22A33}
{3D67E4FF-6EC6-4FE7-82F1-0DACE1E399A7} = {9BAD9352-DEFB-45E5-B8A4-4816B9B22A33}
{46827763-0A5F-47E1-9D6F-9D4BD22883C7} = {760FF85D-8BEB-4992-8095-A9678F88FD47}
{5C356475-B9A6-4CA5-A6BD-0B17FE3FEFC4} = {760FF85D-8BEB-4992-8095-A9678F88FD47}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {F948D667-14E3-4F98-BA50-3F3C948BF4C2}
Expand Down
1 change: 1 addition & 0 deletions src/Samples/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<PropertyGroup>
<!-- Use Samples subdirectory for samples in output folder -->
<OutDirName>Samples\$(MSBuildProjectName)</OutDirName>
<DisableNerdbankVersioning>true</DisableNerdbankVersioning>
</PropertyGroup>

<!-- Import parent props -->
Expand Down
6 changes: 0 additions & 6 deletions src/Samples/Directory.Build.targets

This file was deleted.

1 change: 1 addition & 0 deletions src/Samples/DownloadFile/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
LICENSE
8 changes: 8 additions & 0 deletions src/Samples/DownloadFile/Class1.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
using System;

namespace DownloadFile
{
public class Class1
{
}
}
13 changes: 13 additions & 0 deletions src/Samples/DownloadFile/DownloadFile.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
</PropertyGroup>


<!--
The DownloadFile task was added in 15.8.59, previous versions of MSBuild will just fail so don't import the targets
-->
<Import Project="DownloadFile.targets" Condition=" '$(MSBuildVersion)' != '' And '$(MSBuildVersion)' &gt;= '15.8.59' " />

</Project>
18 changes: 18 additions & 0 deletions src/Samples/DownloadFile/DownloadFile.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd say to not specify the xml header or the namespace in samples, since they're no longer needed.

<Target Name="DownloadLicense"
AfterTargets="PrepareForBuild">

<!-- Download a file -->
<DownloadFile
SourceUrl="https://raw.githubusercontent.com/Microsoft/msbuild/master/LICENSE"
DestinationFolder="$(MSBuildProjectDirectory)">
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you specify a path or something so this can be named DownloadedFile instead of LICENSE? I found the .gitignore confusing.

<Output TaskParameter="DownloadedFile" ItemName="Content" />
</DownloadFile>

<!-- Include the f-->
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the f?

<ItemGroup>
<Content Include="LICENSE" CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>
</Target>
</Project>
8 changes: 8 additions & 0 deletions src/Samples/RoslynCodeTaskFactory/Class1.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
using System;

namespace RoslynCodeTaskFactory
{
public class Class1
{
}
}
12 changes: 12 additions & 0 deletions src/Samples/RoslynCodeTaskFactory/RoslynCodeTaskFactory.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>

<!--
RoslynCodeTaskFactory was added in 15.8.59, previous versions of MSBuild will just fail so don't import the targets
-->
<Import Project="RoslynCodeTaskFactory.targets" Condition=" '$(MSBuildVersion)' != '' And '$(MSBuildVersion)' &gt;= '15.8.59' " />

</Project>
112 changes: 112 additions & 0 deletions src/Samples/RoslynCodeTaskFactory/RoslynCodeTaskFactory.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

<!-- A simple in-line task that logs some messages and returns a string -->
<UsingTask TaskName="MySample"
TaskFactory="RoslynCodeTaskFactory"
AssemblyFile="$(MSBuildBinPath)\Microsoft.Build.Tasks.Core.dll">
<ParameterGroup>
<Parameter1 ParameterType="System.String" Required="true" />
<Parameter2 ParameterType="System.String" />
<Parameter3 ParameterType="System.String" Output="true" />

</ParameterGroup>
<Task>
<Using Namespace="System" />
<Code Type="Fragment" Language="C#">
<![CDATA[
Log.LogMessage(MessageImportance.High, "Hello from an inline task created by Roslyn!");
Log.LogMessageFromText($"Parameter1: '{Parameter1}'", MessageImportance.High);
Log.LogMessageFromText($"Parameter2: '{Parameter2}'", MessageImportance.High);
Parameter3 = "A value from the Roslyn CodeTaskFactory";
]]>
</Code>
</Task>
</UsingTask>

<!-- A simple in-line task that combines paths -->
<UsingTask TaskName="PathCombine"
TaskFactory="RoslynCodeTaskFactory"
AssemblyFile="$(MSBuildBinPath)\Microsoft.Build.Tasks.Core.dll">
<ParameterGroup>
<Paths ParameterType="System.String[]" Required="true" />
<Combined ParameterType="System.String" Output="true" />
</ParameterGroup>
<Task>
<Using Namespace="System" />
<Code Type="Fragment" Language="C#">
<![CDATA[
Combined = Path.Combine(Paths);
]]>
</Code>
</Task>
</UsingTask>

<!-- A simple in-line task that gets the file name of a path -->
<UsingTask TaskName="PathGetFileName"
TaskFactory="RoslynCodeTaskFactory"
AssemblyFile="$(MSBuildBinPath)\Microsoft.Build.Tasks.Core.dll">
<ParameterGroup>
<Path ParameterType="System.String" Required="true" />
<FileName ParameterType="System.String" Output="true" />
</ParameterGroup>
<Task>

<Using Namespace="System" />
<Code Type="Fragment" Language="C#">
<![CDATA[
FileName = System.IO.Path.GetFileName(Path);
]]>
</Code>
</Task>
</UsingTask>

<!-- A simple in-line class task which inherits parameters from its base class -->
<UsingTask TaskName="InterceptingCopy"
TaskFactory="RoslynCodeTaskFactory"
AssemblyFile="$(MSBuildBinPath)\Microsoft.Build.Tasks.Core.dll">
<Task>
<Reference Include="Microsoft.Build.Tasks.Core"/>
<Code Type="Class" Language="cs">
<![CDATA[
using Microsoft.Build.Framework;
using System;

public class InterceptingCopy : Microsoft.Build.Tasks.Copy
{
public override bool Execute()
{
Log.LogMessage(MessageImportance.High, "Copying '{0}' to '{1}'", String.Join(", ", (object[])SourceFiles), String.Join(", ", (object[])DestinationFiles));
return base.Execute();
}
}
]]>
</Code>
</Task>
</UsingTask>

<Target Name="RunSampleTask" AfterTargets="Build">
<!-- Call the compiled task -->
<MySample Parameter1="A value for parameter 1" Parameter2="A value for parameter 2">
<Output TaskParameter="Parameter3" PropertyName="NewProperty" />
</MySample>

<!-- Log whatever text is in NewProperty that came from Parameter3 -->
<Message Text="NewProperty: '$(NewProperty)'" Importance="High" />

<PathCombine Paths="$(Temp);MyFolder;$([System.Guid]::NewGuid()).txt">
<Output TaskParameter="Combined" PropertyName="MyCombinedPaths" />
</PathCombine>

<Message Text="Combined Paths: '$(MyCombinedPaths)'" Importance="High" />

<PathGetFileName Path="$(MyCombinedPaths)">
<Output TaskParameter="FileName" PropertyName="MyFileName" />
</PathGetFileName>

<Message Text="File name: '$(MyFileName)'" Importance="High" />

<InterceptingCopy SourceFiles="Class1.cs" DestinationFiles="$(OutputPath)CopyOfClass1.cs" />
</Target>

</Project>