|
2 | 2 | <Import Project="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.Extensions.targets"/> |
3 | 3 |
|
4 | 4 | <PropertyGroup> |
5 | | - <RoslynCopyToOutDir>true</RoslynCopyToOutDir> |
| 5 | + <RoslynCopyToOutDir Condition="$(RoslynCopyToOutDir) == ''">true</RoslynCopyToOutDir> |
6 | 6 | </PropertyGroup> |
7 | 7 |
|
8 | 8 | <Target Name="SetRoslynCompilerFiles" DependsOnTargets="LocateRoslynCompilerFiles"> |
|
18 | 18 | <ItemGroup> |
19 | 19 | <FilesForPackagingFromProject Include="@(RoslynCompilerFiles)"> |
20 | 20 | <DestinationRelativePath>bin\roslyn\%(RecursiveDir)%(Filename)%(Extension)</DestinationRelativePath> |
| 21 | + <DestinationRelativePath Condition=" '$(WebProjectOutputDir)' == '' ">roslyn\%(RecursiveDir)%(Filename)%(Extension)</DestinationRelativePath> |
21 | 22 | <FromTarget>IncludeRoslynCompilerFilesToFilesForPackagingFromProject</FromTarget> |
22 | 23 | <Category>Run</Category> |
23 | 24 | </FilesForPackagingFromProject> |
24 | 25 | </ItemGroup> |
25 | 26 | </Target> |
26 | 27 |
|
27 | 28 | <Target Name="LocateRoslynToolsDestinationFolder" Condition=" '$(RoslynToolsDestinationFolder)' == '' "> |
28 | | - <!-- Choose one of WebProjectOutputDir or OutputPath --> |
| 29 | + <!-- Choose one of WebProjectOutputDir or OutDir or OutputPath (in that order of preference) --> |
| 30 | + <!-- OutDir and OutputPath are confusing... but usually they are the same. When they differ |
| 31 | + it's likely because somebody is mucking with some intermediate details, but the ultimate |
| 32 | + output destination should be OutDir. For non-web projects. So use that if it exists. --> |
29 | 33 | <PropertyGroup> |
30 | 34 | <RoslynToolsDestinationFolder>$(WebProjectOutputDir)\bin\roslyn</RoslynToolsDestinationFolder> |
31 | | - <RoslynToolsDestinationFolder Condition=" '$(WebProjectOutputDir)' == '' ">$(OutputPath)\roslyn</RoslynToolsDestinationFolder> |
32 | | - </PropertyGroup> |
33 | | - |
34 | | - <!-- But when OutDir is specified there as well --> |
35 | | - <PropertyGroup Condition="'$(OutDir)' != ''"> |
36 | | - <RoslynToolsOutDirFolder>$(OutDir)\bin\roslyn</RoslynToolsOutDirFolder> |
37 | | - <RoslynToolsOutDirFolder Condition=" '$(WebProjectOutputDir)' == '' ">$(OutDir)\roslyn</RoslynToolsOutDirFolder> |
| 35 | + <RoslynToolsDestinationFolder Condition=" '$(WebProjectOutputDir)' == '' ">$(OutDir)\roslyn</RoslynToolsDestinationFolder> |
| 36 | + <RoslynToolsDestinationFolder Condition=" '$(WebProjectOutputDir)' == '' AND '$(OutDir)' == '' ">$(OutputPath)\roslyn</RoslynToolsDestinationFolder> |
38 | 37 | </PropertyGroup> |
39 | 38 | </Target> |
40 | 39 |
|
41 | | - <Target Name="CopyRoslynCompilerFilesToOutputDirectory" AfterTargets="CopyFilesToOutputDirectory" DependsOnTargets="LocateRoslynToolsDestinationFolder;SetRoslynCompilerFiles"> |
| 40 | + <Target Name="CopyRoslynCompilerFilesToOutputDirectory" AfterTargets="CopyFilesToOutputDirectory" DependsOnTargets="LocateRoslynToolsDestinationFolder;SetRoslynCompilerFiles" Condition="$(RoslynCopyToOutDir) == 'true'"> |
42 | 41 | <Copy SourceFiles="@(RoslynCompilerFiles)" DestinationFolder="$(RoslynToolsDestinationFolder)" ContinueOnError="true" SkipUnchangedFiles="true" Retries="0" /> |
43 | 42 | <ItemGroup Condition="'$(MSBuildLastTaskResult)' == 'True'" > |
44 | 43 | <FileWrites Include="$(RoslynToolsDestinationFolder)\*" /> |
45 | 44 | </ItemGroup> |
46 | | - <Copy SourceFiles="@(RoslynCompilerFiles)" DestinationFolder="$(RoslynToolsOutDirFolder)" Condition="'$(RoslynToolsOutDirFolder)' != '$(RoslynToolsDestinationFolder)'" ContinueOnError="true" SkipUnchangedFiles="true" Retries="0" /> |
47 | | - <ItemGroup Condition="'$(RoslynToolsOutDirFolder)' != '$(RoslynToolsDestinationFolder)' AND '$(MSBuildLastTaskResult)' == 'True'" > |
48 | | - <FileWrites Include="$(RoslynToolsOutDirFolder)\*" /> |
49 | | - </ItemGroup> |
50 | 45 | </Target> |
51 | 46 |
|
52 | 47 | <Target Name="CheckIfShouldKillVBCSCompiler" DependsOnTargets="LocateRoslynCompilerFiles;LocateRoslynToolsDestinationFolder"> |
|
0 commit comments