diff --git a/Roslyn.sln b/Roslyn.sln index 1de8f87515814044c6c9b8b31930b5e3dc04b56d..ae17d51ae20e4d90d15ee929e4c32f03a7196ec5 100644 --- a/Roslyn.sln +++ b/Roslyn.sln @@ -1,5 +1,4 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 +Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 14 VisualStudioVersion = 14.0.23025.0 MinimumVisualStudioVersion = 10.0.40219.1 @@ -285,6 +284,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CSharpWinRTTest", "src\Comp EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MSBuildTask", "src\Compilers\Core\MSBuildTask\MSBuildTask.csproj", "{D874349C-8BB3-4BDC-8535-2D52CCCA1198}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MSBuildTaskTests", "src\Compilers\Core\MSBuildTaskTests\MSBuildTaskTests.csproj", "{1DFEA9C5-973C-4179-9B1B-0F32288E1EF2}" +EndProject Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "BasicResultProvider", "src\ExpressionEvaluator\VisualBasic\Source\ResultProvider\BasicResultProvider.shproj", "{3140FE61-0856-4367-9AA3-8081B9A80E35}" EndProject Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "BasicResultProvider.NetFX20", "src\ExpressionEvaluator\VisualBasic\Source\ResultProvider\NetFX20\BasicResultProvider.NetFX20.vbproj", "{76242A2D-2600-49DD-8C15-FEA07ECB1842}" @@ -5576,6 +5577,22 @@ Global {06ECCF53-B9B8-4CC2-83C0-E308BF645F7F}.Release|x64.Build.0 = Release|Any CPU {06ECCF53-B9B8-4CC2-83C0-E308BF645F7F}.Release|x86.ActiveCfg = Release|Any CPU {06ECCF53-B9B8-4CC2-83C0-E308BF645F7F}.Release|x86.Build.0 = Release|Any CPU + {1DFEA9C5-973C-4179-9B1B-0F32288E1EF2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1DFEA9C5-973C-4179-9B1B-0F32288E1EF2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1DFEA9C5-973C-4179-9B1B-0F32288E1EF2}.Debug|ARM.ActiveCfg = Debug|ARM + {1DFEA9C5-973C-4179-9B1B-0F32288E1EF2}.Debug|ARM.Build.0 = Debug|ARM + {1DFEA9C5-973C-4179-9B1B-0F32288E1EF2}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {1DFEA9C5-973C-4179-9B1B-0F32288E1EF2}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {1DFEA9C5-973C-4179-9B1B-0F32288E1EF2}.Debug|x64.ActiveCfg = Debug|x64 + {1DFEA9C5-973C-4179-9B1B-0F32288E1EF2}.Debug|x64.Build.0 = Debug|x64 + {1DFEA9C5-973C-4179-9B1B-0F32288E1EF2}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1DFEA9C5-973C-4179-9B1B-0F32288E1EF2}.Release|Any CPU.Build.0 = Release|Any CPU + {1DFEA9C5-973C-4179-9B1B-0F32288E1EF2}.Release|ARM.ActiveCfg = Release|ARM + {1DFEA9C5-973C-4179-9B1B-0F32288E1EF2}.Release|ARM.Build.0 = Release|ARM + {1DFEA9C5-973C-4179-9B1B-0F32288E1EF2}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {1DFEA9C5-973C-4179-9B1B-0F32288E1EF2}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {1DFEA9C5-973C-4179-9B1B-0F32288E1EF2}.Release|x64.ActiveCfg = Release|x64 + {1DFEA9C5-973C-4179-9B1B-0F32288E1EF2}.Release|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -5734,5 +5751,6 @@ Global {2491A9B9-C0A8-49EE-9077-A32DE76E1E94} = {999FBDA2-33DA-4F74-B957-03AC72CCE5EC} {5CA5F70E-0FDB-467B-B22C-3CD5994F0087} = {999FBDA2-33DA-4F74-B957-03AC72CCE5EC} {81F048A1-B30A-4E74-9BD3-2655DA1DBEA6} = {999FBDA2-33DA-4F74-B957-03AC72CCE5EC} + {1DFEA9C5-973C-4179-9B1B-0F32288E1EF2} = {A41D1B99-F489-4C43-BBDF-96D61B19A6B9} EndGlobalSection EndGlobal diff --git a/build/Toolset.sln b/build/Toolset.sln index 2e99f4e0cf5a4b7b9f6eada9c4a12d9e80052a67..940b3dcf5b47dc2cd71ed4f7b4bc0b4cd9459ab2 100644 --- a/build/Toolset.sln +++ b/build/Toolset.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 14 -VisualStudioVersion = 14.0.22725.0 +VisualStudioVersion = 14.0.23025.0 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CodeAnalysisTest", "..\src\Compilers\Core\CodeAnalysisTest\CodeAnalysisTest.csproj", "{A4C99B85-765C-4C65-9C2A-BB609AAB09E6}" EndProject @@ -11,11 +11,11 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VBCSCompiler", "..\src\Comp EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VBCSCompilerTests", "..\src\Compilers\Core\VBCSCompilerTests\VBCSCompilerTests.csproj", "{F5CE416E-B906-41D2-80B9-0078E887A3F6}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Core", "..\src\Core", "{A41D1B99-F489-4C43-BBDF-96D61B19A6B9}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Core", "Core", "{A41D1B99-F489-4C43-BBDF-96D61B19A6B9}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Compilers", "..\src\Compilers", "{3F40F71B-7DCF-44A1-B15C-38CA34824143}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Compilers", "Compilers", "{3F40F71B-7DCF-44A1-B15C-38CA34824143}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "CSharp", "..\src\CSharp", "{32A48625-F0AD-419D-828B-A50BDABA38EA}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "CSharp", "CSharp", "{32A48625-F0AD-419D-828B-A50BDABA38EA}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "csc", "..\src\Compilers\CSharp\csc\csc.csproj", "{4B45CA0C-03A0-400F-B454-3D4BCB16AF38}" EndProject @@ -31,7 +31,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CSharpCompilerSymbolTest", EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CSharpCompilerSyntaxTest", "..\src\Compilers\CSharp\Test\Syntax\CSharpCompilerSyntaxTest.csproj", "{50D26304-0961-4A51-ABF6-6CAD1A56D202}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "VisualBasic", "..\src\VisualBasic", "{C65C6143-BED3-46E6-869E-9F0BE6E84C37}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "VisualBasic", "VisualBasic", "{C65C6143-BED3-46E6-869E-9F0BE6E84C37}" EndProject Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "CompilerTestResources", "..\src\Compilers\Test\Resources\Core\CompilerTestResources.vbproj", "{7FE6B002-89D8-4298-9B1B-0B5C247DD1FD}" EndProject @@ -57,18 +57,18 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PdbUtilities", "..\src\Test EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestUtilities", "..\src\Test\Utilities\TestUtilities.csproj", "{76C6F005-C89D-4348-BB4A-391898DBEB52}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Workspaces", "..\src\Workspaces", "{55A62CFA-1155-46F1-ADF3-BEEE51B58AB5}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Workspaces", "Workspaces", "{55A62CFA-1155-46F1-ADF3-BEEE51B58AB5}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Workspaces", "..\src\Workspaces\Core\Portable\Workspaces.csproj", "{5F8D2414-064A-4B3A-9B42-8E2A04246BE5}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", "..\src\.nuget", "{C41FAB9A-D1D7-4253-B639-D72395B6BA37}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{C41FAB9A-D1D7-4253-B639-D72395B6BA37}" ProjectSection(SolutionItems) = preProject .nuget\NuGet.Config = .nuget\NuGet.Config .nuget\NuGet.exe = .nuget\NuGet.exe .nuget\NuGet.targets = .nuget\NuGet.targets EndProjectSection EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tools", "..\src\Tools", "{FD0FAF5F-1DED-485C-99FA-84B97F3A8EEC}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tools", "Tools", "{FD0FAF5F-1DED-485C-99FA-84B97F3A8EEC}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CompilersBoundTreeGenerator", "..\src\Tools\Source\CompilerGeneratorTools\Source\BoundTreeGenerator\CompilersBoundTreeGenerator.csproj", "{02459936-CD2C-4F61-B671-5C518F2A3DDC}" EndProject @@ -98,7 +98,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CSharpFeatures", "..\src\Fe EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Features", "..\src\Features\Core\Features.csproj", "{EDC68A0E-C68D-4A74-91B7-BF38EC909888}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Features", "..\src\Features", "{3E5FE3DB-45F7-4D83-9097-8F05D3B3AEC6}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Features", "Features", "{3E5FE3DB-45F7-4D83-9097-8F05D3B3AEC6}" EndProject Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "AnalyzerDriver", "..\src\Compilers\Core\AnalyzerDriver\AnalyzerDriver.shproj", "{D0BC9BE7-24F6-40CA-8DC6-FCB93BD44B34}" EndProject @@ -114,6 +114,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "vbc2", "..\src\Compilers\Vi EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "vbc", "..\src\Compilers\VisualBasic\vbc\vbc.csproj", "{E58EE9D7-1239-4961-A0C1-F9EC3952C4C1}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MSBuildTaskTests", "..\src\Compilers\Core\MSBuildTaskTests\MSBuildTaskTests.csproj", "{1DFEA9C5-973C-4179-9B1B-0F32288E1EF2}" +EndProject Global GlobalSection(SharedMSBuildProjectFiles) = preSolution ..\src\Compilers\Core\AnalyzerDriver\AnalyzerDriver.projitems*{edc68a0e-c68d-4a74-91b7-bf38ec909888}*SharedItemsImports = 4 @@ -121,8 +123,8 @@ Global ..\src\Compilers\Core\AnalyzerDriver\AnalyzerDriver.projitems*{d0bc9be7-24f6-40ca-8dc6-fcb93bd44b34}*SharedItemsImports = 13 ..\src\Compilers\VisualBasic\BasicAnalyzerDriver\BasicAnalyzerDriver.projitems*{a1bcd0ce-6c2f-4f8c-9a48-d9d93928e26d}*SharedItemsImports = 4 ..\src\Compilers\Core\SharedCollections\SharedCollections.projitems*{afde6bea-5038-4a4a-a88e-dbd2e4088eed}*SharedItemsImports = 4 - ..\src\Compilers\Core\AnalyzerDriver\AnalyzerDriver.projitems*{1ee8cad3-55f9-4d91-96b2-084641da9a6c}*SharedItemsImports = 4 ..\src\Compilers\Core\SharedCollections\SharedCollections.projitems*{1ee8cad3-55f9-4d91-96b2-084641da9a6c}*SharedItemsImports = 4 + ..\src\Compilers\Core\AnalyzerDriver\AnalyzerDriver.projitems*{1ee8cad3-55f9-4d91-96b2-084641da9a6c}*SharedItemsImports = 4 ..\src\Compilers\CSharp\CSharpAnalyzerDriver\CSharpAnalyzerDriver.projitems*{3973b09a-4fbf-44a5-8359-3d22ceb71f71}*SharedItemsImports = 4 ..\src\Compilers\CSharp\CSharpAnalyzerDriver\CSharpAnalyzerDriver.projitems*{b501a547-c911-4a05-ac6e-274a50dff30e}*SharedItemsImports = 4 ..\src\Compilers\VisualBasic\BasicAnalyzerDriver\BasicAnalyzerDriver.projitems*{2523d0e6-df32-4a3e-8ae0-a19bffae2ef6}*SharedItemsImports = 4 @@ -825,6 +827,22 @@ Global {E58EE9D7-1239-4961-A0C1-F9EC3952C4C1}.Release|Mixed Platforms.Build.0 = Release|Any CPU {E58EE9D7-1239-4961-A0C1-F9EC3952C4C1}.Release|x64.ActiveCfg = Release|x64 {E58EE9D7-1239-4961-A0C1-F9EC3952C4C1}.Release|x64.Build.0 = Release|x64 + {1DFEA9C5-973C-4179-9B1B-0F32288E1EF2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1DFEA9C5-973C-4179-9B1B-0F32288E1EF2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1DFEA9C5-973C-4179-9B1B-0F32288E1EF2}.Debug|ARM.ActiveCfg = Debug|ARM + {1DFEA9C5-973C-4179-9B1B-0F32288E1EF2}.Debug|ARM.Build.0 = Debug|ARM + {1DFEA9C5-973C-4179-9B1B-0F32288E1EF2}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {1DFEA9C5-973C-4179-9B1B-0F32288E1EF2}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {1DFEA9C5-973C-4179-9B1B-0F32288E1EF2}.Debug|x64.ActiveCfg = Debug|x64 + {1DFEA9C5-973C-4179-9B1B-0F32288E1EF2}.Debug|x64.Build.0 = Debug|x64 + {1DFEA9C5-973C-4179-9B1B-0F32288E1EF2}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1DFEA9C5-973C-4179-9B1B-0F32288E1EF2}.Release|Any CPU.Build.0 = Release|Any CPU + {1DFEA9C5-973C-4179-9B1B-0F32288E1EF2}.Release|ARM.ActiveCfg = Release|ARM + {1DFEA9C5-973C-4179-9B1B-0F32288E1EF2}.Release|ARM.Build.0 = Release|ARM + {1DFEA9C5-973C-4179-9B1B-0F32288E1EF2}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {1DFEA9C5-973C-4179-9B1B-0F32288E1EF2}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {1DFEA9C5-973C-4179-9B1B-0F32288E1EF2}.Release|x64.ActiveCfg = Release|x64 + {1DFEA9C5-973C-4179-9B1B-0F32288E1EF2}.Release|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -878,5 +896,6 @@ Global {C545216D-8CBA-4460-810D-D3DC7EFF8373} = {32A48625-F0AD-419D-828B-A50BDABA38EA} {21446697-E359-41D9-B39D-40ADA2B20823} = {C65C6143-BED3-46E6-869E-9F0BE6E84C37} {E58EE9D7-1239-4961-A0C1-F9EC3952C4C1} = {C65C6143-BED3-46E6-869E-9F0BE6E84C37} + {1DFEA9C5-973C-4179-9B1B-0F32288E1EF2} = {A41D1B99-F489-4C43-BBDF-96D61B19A6B9} EndGlobalSection EndGlobal diff --git a/src/Compilers/Core/MSBuildTask/ManagedCompiler.cs b/src/Compilers/Core/MSBuildTask/ManagedCompiler.cs index 4d25556439c607e5512f55d814904d0815d283e1..746ee42dfe0b2ac766c1a7f5712263091429e75d 100644 --- a/src/Compilers/Core/MSBuildTask/ManagedCompiler.cs +++ b/src/Compilers/Core/MSBuildTask/ManagedCompiler.cs @@ -479,6 +479,11 @@ private void LogErrorOutput(string output) /// internal abstract void LogMessages(string output, MessageImportance messageImportance); + public string GenerateResponseFileContents() + { + return GenerateResponseFileCommands(); + } + /// /// Get the command line arguments to pass to the compiler. /// diff --git a/src/Compilers/Core/MSBuildTaskTests/AssemblyAttributes.cs b/src/Compilers/Core/MSBuildTaskTests/AssemblyAttributes.cs new file mode 100644 index 0000000000000000000000000000000000000000..e8f2354bfbf3448fb48fe9bdae457ce111578e71 --- /dev/null +++ b/src/Compilers/Core/MSBuildTaskTests/AssemblyAttributes.cs @@ -0,0 +1,4 @@ +// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using Xunit; + diff --git a/src/Compilers/Core/MSBuildTaskTests/CscTests.cs b/src/Compilers/Core/MSBuildTaskTests/CscTests.cs new file mode 100644 index 0000000000000000000000000000000000000000..c2473297fee1c4d77e165d9f8c6ba856f9d8ef5b --- /dev/null +++ b/src/Compilers/Core/MSBuildTaskTests/CscTests.cs @@ -0,0 +1,73 @@ +// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Linq; +using Microsoft.Build.Framework; +using Microsoft.CodeAnalysis.BuildTasks; +using Xunit; +using Moq; + +namespace Microsoft.CodeAnalysis.BuildTasks.UnitTests +{ + public sealed class CscTests + { + [Fact] + public void SingleSource() + { + var csc = new Csc(); + csc.Sources = MSBuildUtil.CreateTaskItems("test.cs"); + Assert.Equal("/out:test.exe test.cs", csc.GenerateResponseFileContents()); + } + + [Fact] + public void MultipleSourceFiles() + { + var csc = new Csc(); + csc.Sources = MSBuildUtil.CreateTaskItems("test1.cs", "test2.cs"); + Assert.Equal("/out:test1.exe test1.cs test2.cs", csc.GenerateResponseFileContents()); + } + + [Fact] + public void TargetTypeDll() + { + var csc = new Csc(); + csc.TargetType = "library"; + csc.Sources = MSBuildUtil.CreateTaskItems("test.cs"); + Assert.Equal("/out:test.dll /target:library test.cs", csc.GenerateResponseFileContents()); + } + + [Fact] + public void TargetTypeBad() + { + var csc = new Csc(); + csc.TargetType = "bad"; + csc.Sources = MSBuildUtil.CreateTaskItems("test.cs"); + Assert.Equal("/out:test.exe /target:bad test.cs", csc.GenerateResponseFileContents()); + } + + [Fact] + public void OutputAssembly() + { + var csc = new Csc(); + csc.Sources = MSBuildUtil.CreateTaskItems("test.cs"); + csc.OutputAssembly = MSBuildUtil.CreateTaskItem("x.exe"); + Assert.Equal("/out:x.exe test.cs", csc.GenerateResponseFileContents()); + } + + [Fact] + public void DefineConstantsSimple() + { + Action test = (s) => + { + var csc = new Csc(); + csc.DefineConstants = s; + csc.Sources = MSBuildUtil.CreateTaskItems("test.cs"); + Assert.Equal("/define:D1;D2 /out:test.exe test.cs", csc.GenerateResponseFileContents()); + }; + + test("D1;D2"); + test("D1,D2"); + test("D1 D2"); + } + } +} diff --git a/src/Compilers/Core/MSBuildTaskTests/MSBuildTaskTests.csproj b/src/Compilers/Core/MSBuildTaskTests/MSBuildTaskTests.csproj new file mode 100644 index 0000000000000000000000000000000000000000..77c0c933add650d1af4775953d0c5385799d62a4 --- /dev/null +++ b/src/Compilers/Core/MSBuildTaskTests/MSBuildTaskTests.csproj @@ -0,0 +1,118 @@ + + + + + + + + true + Debug + AnyCPU + {1DFEA9C5-973C-4179-9B1B-0F32288E1EF2} + Library + Microsoft.CodeAnalysis.BuildTasks.UnitTests + Microsoft.Build.Tasks.CodeAnalysis.UnitTests + true + ..\..\..\..\ + true + v4.5 + + + + {AFDE6BEA-5038-4A4A-A88E-DBD2E4088EED} + PdbUtilities + + + {76C6F005-C89D-4348-BB4A-391898DBEB52} + TestUtilities + + + {7FE6B002-89D8-4298-9B1B-0B5C247DD1FD} + CompilerTestResources + + + {F7712928-1175-47B3-8819-EE086753DEE2} + CompilerTestUtilities2 + + + {d874349c-8bb3-4bdc-8535-2d52ccca1198} + MSBuildTask + + + {1ee8cad3-55f9-4d91-96b2-084641da9a6c} + CodeAnalysis + + + + + + + + + $(MSBuildProgramFiles32)\Reference Assemblies\Microsoft\MSBuild\v14.0\Microsoft.Build.Framework.dll + + + False + $(MSBuildProgramFiles32)\Reference Assemblies\Microsoft\MSBuild\v14.0\Microsoft.Build.Utilities.Core.dll + + + ..\..\..\..\packages\xunit.1.9.2\lib\net20\xunit.dll + + + + + + + + ARM + + + ARM + + + true + ..\..\..\..\Binaries\Debug\amd64 + true + true + 1591 + full + x64 + prompt + MinimumRecommendedRules.ruleset + + + ..\..\..\..\Binaries\Release\amd64 + true + true + 1591 + pdbonly + x64 + prompt + MinimumRecommendedRules.ruleset + + + + False + ..\..\..\..\packages\Microsoft.CodeAnalysis.Test.Resources.Proprietary.1.0.0-rc3-20150528-03\lib\net45\Microsoft.CodeAnalysis.Test.Resources.Proprietary.dll + + + + + + + + + + + + + + + + Designer + + + + + + diff --git a/src/Compilers/Core/MSBuildTaskTests/MSBuildUtil.cs b/src/Compilers/Core/MSBuildTaskTests/MSBuildUtil.cs new file mode 100644 index 0000000000000000000000000000000000000000..31f1c3009106e9028bc6a3c1423910bb44c2c237 --- /dev/null +++ b/src/Compilers/Core/MSBuildTaskTests/MSBuildUtil.cs @@ -0,0 +1,27 @@ +// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using Microsoft.Build.Framework; +using Moq; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Microsoft.CodeAnalysis.BuildTasks.UnitTests +{ + internal static class MSBuildUtil + { + public static ITaskItem[] CreateTaskItems(params string[] fileNames) + { + return fileNames.Select(CreateTaskItem).ToArray(); + } + + public static ITaskItem CreateTaskItem(string fileName) + { + var taskItem = new Mock(MockBehavior.Strict); + taskItem.Setup(x => x.ItemSpec).Returns(fileName); + return taskItem.Object; + } + } +} diff --git a/src/Compilers/Core/MSBuildTaskTests/VbcTests.cs b/src/Compilers/Core/MSBuildTaskTests/VbcTests.cs new file mode 100644 index 0000000000000000000000000000000000000000..4231a776b0e8247c27db012e85b5d8bd8e91d448 --- /dev/null +++ b/src/Compilers/Core/MSBuildTaskTests/VbcTests.cs @@ -0,0 +1,70 @@ +// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using Microsoft.CodeAnalysis.BuildTasks; +using Xunit; + +namespace Microsoft.CodeAnalysis.BuildTasks.UnitTests +{ + public sealed class VbcTests + { + [Fact] + public void SingleSource() + { + var vbc = new Vbc(); + vbc.Sources = MSBuildUtil.CreateTaskItems("test.vb"); + Assert.Equal("/optionstrict:custom /out:test.exe test.vb", vbc.GenerateResponseFileContents()); + } + + [Fact] + public void MultipleSourceFiles() + { + var vbc = new Vbc(); + vbc.Sources = MSBuildUtil.CreateTaskItems("test1.vb", "test2.vb"); + Assert.Equal("/optionstrict:custom /out:test1.exe test1.vb test2.vb", vbc.GenerateResponseFileContents()); + } + + [Fact] + public void TargetTypeDll() + { + var vbc = new Vbc(); + vbc.Sources = MSBuildUtil.CreateTaskItems("test.vb"); + vbc.TargetType = "library"; + Assert.Equal("/optionstrict:custom /out:test.dll /target:library test.vb", vbc.GenerateResponseFileContents()); + } + + [Fact] + public void TargetTypeBad() + { + var vbc = new Vbc(); + vbc.Sources = MSBuildUtil.CreateTaskItems("test.vb"); + vbc.TargetType = "bad"; + Assert.Equal("/optionstrict:custom /out:test.exe /target:bad test.vb", vbc.GenerateResponseFileContents()); + } + + [Fact] + public void OutputAssembly() + { + var vbc = new Vbc(); + vbc.OutputAssembly = MSBuildUtil.CreateTaskItem("x.exe"); + vbc.Sources = MSBuildUtil.CreateTaskItems("test.vb"); + Assert.Equal("/optionstrict:custom /out:x.exe test.vb", vbc.GenerateResponseFileContents()); + } + + [Fact] + public void DefineConstantsSimple() + { + Action test = (s) => + { + var vbc = new Vbc(); + vbc.DefineConstants = s; + vbc.Sources = MSBuildUtil.CreateTaskItems("test.vb"); + Assert.Equal($@"/optionstrict:custom /define:""{s}"" /out:test.exe test.vb", vbc.GenerateResponseFileContents()); + }; + + test("D1;D2"); + test("D1,D2"); + test("D1 D2"); + } + } +} diff --git a/src/Compilers/Core/MSBuildTaskTests/packages.config b/src/Compilers/Core/MSBuildTaskTests/packages.config new file mode 100644 index 0000000000000000000000000000000000000000..ff04663408cf1e2ea3e976f1819a4b3953231c0c --- /dev/null +++ b/src/Compilers/Core/MSBuildTaskTests/packages.config @@ -0,0 +1,7 @@ + + + + + + +