<Target Name="BeforeBuild" Inputs="Hello.ice" Outputs="generated/Hello.cs">
<Exec Condition="Exists('D:/ZeroC/Ice-3.4.1/slice')" Command="D:/ZeroC/Ice-3.4.1/bin/slice2cs.exe --Hello.ice" />
</Target>
played around with this approach and it seems the following recipe works also:
- Add your Slice files to a Visual Studio project and on their properties page assign them a custom Build Action name, e.g. "Slice".
- Add the files to be generated (as empty code files, for instance) and on their properties page assign them a custom Build Action name, e.g. "SliceGenerated".
- Add this <Compile> item in the project file:
Code:<ItemGroup> . . . <Compile Include="@(SliceGenerated)"> <Visible>False</Visible> </Compile> . . . </ItemGroup>
- Paste this to the end of the project file (part of it copied from ZeroC demo projects):
Code:<Target Name="CompileSlice" Inputs="@(Slice)" Outputs="@(SliceGenerated)"> <Exec Command="%25ICE_HOME%25/bin/slice2cs.exe -I"../slice" --output-dir generated @(Slice->'"%(Identity)"', ' ')" /> </Target> <Target Name="AfterClean"> <Delete Files="@(SliceGenerated)" /> </Target> <PropertyGroup> <CompileDependsOn> CompileSlice;$(CompileDependsOn) </CompileDependsOn> </PropertyGroup>