Skip to content

Commit 92d9ff7

Browse files
Handle OutDir when building in msbuild instead of VS. (#130)
1 parent ee49835 commit 92d9ff7

1 file changed

Lines changed: 15 additions & 5 deletions

File tree

src/Packages/Microsoft.CodeDom.Providers.DotNetCompilerPlatform/build/Microsoft.CodeDom.Providers.DotNetCompilerPlatform.targets

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
22
<Import Project="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.Extensions.targets"/>
33

4+
<PropertyGroup>
5+
<RoslynCopyToOutDir>true</RoslynCopyToOutDir>
6+
</PropertyGroup>
7+
48
<Target Name="SetRoslynCompilerFiles" DependsOnTargets="LocateRoslynCompilerFiles">
59
<Message Text="Using Roslyn from '$(RoslynToolPath)' folder" />
610
<ItemGroup>
@@ -21,14 +25,20 @@
2125
</Target>
2226

2327
<Target Name="LocateRoslynToolsDestinationFolder" Condition=" '$(RoslynToolsDestinationFolder)' == '' ">
24-
<PropertyGroup>
25-
<RoslynToolsDestinationFolder>$(WebProjectOutputDir)\bin\roslyn</RoslynToolsDestinationFolder>
26-
<RoslynToolsDestinationFolder Condition=" '$(WebProjectOutputDir)' == '' ">$(OutputPath)\roslyn</RoslynToolsDestinationFolder>
27-
</PropertyGroup>
28+
<!-- Choose one of WebProjectOutputDir or OutputPath -->
29+
<!-- But when OutDir is specified given and is different from that choice, also include it without 'bin' -->
30+
<ItemGroup Condition="'$(WebProjectOutputDir)' != ''">
31+
<RoslynToolsDestinations Include="$(WebProjectOutputDir)\bin\roslyn" />
32+
<RoslynToolsDestinations Condition="'$(RoslynCopyToOutDir)' == 'true' AND '$(OutDir)' != '$(WebProjectOutputDir)'" Include="$(OutDir)\roslyn" />
33+
</ItemGroup>
34+
<ItemGroup Condition="'$(WebProjectOutputDir)' == ''">
35+
<RoslynToolsDestinations Include="$(OutputPath)\bin\roslyn" />
36+
<RoslynToolsDestinations Condition="'$(RoslynCopyToOutDir)' == 'true' AND '$(OutDir)' != '$(OutputPath)'" Include="$(OutDir)\roslyn" />
37+
</ItemGroup>
2838
</Target>
2939

3040
<Target Name="CopyRoslynCompilerFilesToOutputDirectory" AfterTargets="CopyFilesToOutputDirectory" DependsOnTargets="LocateRoslynToolsDestinationFolder;SetRoslynCompilerFiles">
31-
<Copy SourceFiles="@(RoslynCompilerFiles)" DestinationFolder="$(RoslynToolsDestinationFolder)" ContinueOnError="true" SkipUnchangedFiles="true" Retries="0" />
41+
<Copy SourceFiles="@(RoslynCompilerFiles)" DestinationFolder="%(RoslynToolsDestinations.FullPath)" ContinueOnError="true" SkipUnchangedFiles="true" Retries="0" />
3242
<ItemGroup Condition="'$(MSBuildLastTaskResult)' == 'True'" >
3343
<FileWrites Include="$(RoslynToolsDestinationFolder)\*" />
3444
</ItemGroup>

0 commit comments

Comments
 (0)