codeformatter icon indicating copy to clipboard operation
codeformatter copied to clipboard

Add commandline switch to conditionally include project files based on msbuild conditions.

Open Priya91 opened this issue 8 years ago • 1 comments

Is there a way to do this with .net compiler platform?

For ex, one of the project files in corefx:

 <ItemGroup Condition="'$(TargetsFreeBSD)'=='true'">
    <Compile Include="RuntimeInformation.FreeBSD.cs" />
  </ItemGroup>
  <ItemGroup Condition="'$(TargetsLinux)'=='true'">
    <Compile Include="RuntimeInformation.Linux.cs" />
  </ItemGroup>

Is there a way to format all files in the project, which may or may not be in compilation based on msbuild conditions.

cc @srivatsn @jaredpar @mellinoe

Priya91 avatar Jan 05 '16 00:01 Priya91

Not directly. MSBuild evaluates those conditions and drops those files before passing them to Roslyn. You'll have to parse the csproj files, identify all such conditions and recreate compilations with those constants set. I believe codeformatter already has some code for creating compilations for different sets of conditional constants taken from the commandline but I could be wrong.

srivatsn avatar Jan 05 '16 00:01 srivatsn