Results 1 to 10 of 10

Thread: Gauging interest: Visual Studio custom tool for Slice files

  1. #1
    csammis's Avatar
    csammis is offline Registered User
    Name: chris sammis
    Organization: blank
    Project: blank
    Join Date
    Jul 2005
    Posts
    4

    Lightbulb Gauging interest: Visual Studio custom tool for Slice files

    Hello all -

    I've been working with Ice for several months now, we use it to communicate between C++ data servers and C# client apps. On the C# side, most of us use Visual Studio 2003 to do our development. We have a project, call it IceClient, that encapsulates the classes generated by slice2cs, and the rest of our projects contain a reference to the IceClient project.

    The problem (as I see it) with this setup is the way that we use slice2cs in the IceClient project: a pre-build step is used to call slice2cs on our Slice files. This has the unfortunate side-effect of rebuilding the C# files each time, which causes the IceClient project to have to rebuild itself each time, which causes all projects that are dependent on IceClient to rebuild...it's a time-consumer.

    To fix that, I've written a custom tool for VS 2003 that understands how to handle Slice files. The Slice file is included in the project, its "Custom Tool" property is set to "vsSlice" (the name of the tool), and the problem is solved: VS now knows enough to only regenerate the C# when the interface file has changed, which means that the cascading rebuilds don't happen and overall compile time is usually sped up.

    What I'm wondering now: Would anyone else be interested in this tool for their own use? I've found it pretty handy, and I'd like to share it if there's interest -- plus, other people using it will allow me to test it outside of our own build environment, always a good thing


    (mods, if this thread would be better served in another forum, please move)

  2. #2
    michi's Avatar
    michi is offline Registered User
    Name: Michi Henning
    Organization: Triodia Technologies
    Project: I have a passing interest in Ice :-)
    Join Date
    Feb 2003
    Location
    Brisbane, Australia
    Posts
    1,055
    Feel free to post any tools you want to share here.

    BTW, the icecs source tree includes a tool that does just that: finds all the Slice files and compiles them only if they are newer than the corresponding generated .cs files. You can find the code for this in the generate subdirectory of the icecs tree.

    The tool isn't terribly sophisticated, but good enough to support the build for icecs. (Unfortunately, support for custom build steps is rather rudimentary with VS for C#, and even more rudimentary with VS for VB, so you end up having to write tools such as this...)

    Cheers,

    Michi.

  3. #3
    sylvain is offline Registered User
    Name: Sylvain Fasel
    Organization: university of Geneva
    Project: quantum cryptographic systems
    Join Date
    Feb 2003
    Location
    Geneva (Switzerland)
    Posts
    42

    Thumbs up ... still available?

    Hi Csammis,

    I was just about to start building from scratch the "Custom Tool" you describe in you post (with no idea on how to do it), for exactly the same reason you first made it.

    Your post is about 2 years old, but are you still using your tool, and are you still ok to share it?

    I have to say we use VisualStudio 2005, but it is probably the case for you too, and your tool might work as is in VS2005.

    Anyway, I would be quite happy to get it if you don't mind, for sure it will be quite useful for me.

    Thanks in advance.
    Sylvain Fasel
    Group of Applied Physics
    University of Geneva
    www.gapoptic.unige.ch
    Research in applied quantum cryptography

  4. #4
    csammis's Avatar
    csammis is offline Registered User
    Name: chris sammis
    Organization: blank
    Project: blank
    Join Date
    Jul 2005
    Posts
    4
    Sorry sylvain, I no longer work at the company where I used Ice.

  5. #5
    sylvain is offline Registered User
    Name: Sylvain Fasel
    Organization: university of Geneva
    Project: quantum cryptographic systems
    Join Date
    Feb 2003
    Location
    Geneva (Switzerland)
    Posts
    42
    Hi Csammis,

    Ok, thanks for your reply anyway.

    I will thus develop the Custom Tool myself, and post it here if it seems to work.

    Regards.
    Sylvain Fasel
    Group of Applied Physics
    University of Geneva
    www.gapoptic.unige.ch
    Research in applied quantum cryptography

  6. #6
    dwayne's Avatar
    dwayne is offline ZeroC Staff
    Name: Dwayne Boone
    Organization: ZeroC, Inc.
    Project: Internet Communications Engine
    Join Date
    Jan 2005
    Location
    St. John's, Newfoundland
    Posts
    397
    Have you looked at what we do in the demo project files? Since we no longer support VS 2003, the slice compilation is now part of the project rather than an external tool.

  7. #7
    sylvain is offline Registered User
    Name: Sylvain Fasel
    Organization: university of Geneva
    Project: quantum cryptographic systems
    Join Date
    Feb 2003
    Location
    Geneva (Switzerland)
    Posts
    42
    Hi Dwayne,

    thanks for your reply!

    Well, I did look at your demo-projects, and indeed .ice files are slice2cs'ed before the build start.

    I managed to find the lines
    <Target Name="CompileSlice" Inputs="Hello.ice" Outputs="generated\Hello.cs">
    <Exec Condition="Exists('..\..\..\slice')" Command="..\..\..\bin\slice2cs.exe --output-dir generated Hello.ice" />
    <Exec Condition="Exists('..\..\..\..\slice')" Command="..\..\..\..\cpp\bin\slice2cs.exe --output-dir generated Hello.ice" />
    </Target>

    in the .csproj fille, but I have not been able to find a way to edit or add this using project properties from VisualStudio. How did you do that??

    I have to say that your solution might be nice to start with, but will not replace the Custom Tool stuff. Indeed, using a Custom Tool will make .ice files to be sliced anytime you save them.
    This is nice if you use tools like Resharper that parse code and find errors without the need to compile.

    Thanks again.
    Regards.
    Sylvain Fasel
    Group of Applied Physics
    University of Geneva
    www.gapoptic.unige.ch
    Research in applied quantum cryptography

  8. #8
    dwayne's Avatar
    dwayne is offline ZeroC Staff
    Name: Dwayne Boone
    Organization: ZeroC, Inc.
    Project: Internet Communications Engine
    Join Date
    Jan 2005
    Location
    St. John's, Newfoundland
    Posts
    397
    Quote Originally Posted by sylvain View Post
    Well, I did look at your demo-projects, and indeed .ice files are slice2cs'ed before the build start.

    I managed to find the lines
    <Target Name="CompileSlice" Inputs="Hello.ice" Outputs="generated\Hello.cs">
    <Exec Condition="Exists('..\..\..\slice')" Command="..\..\..\bin\slice2cs.exe --output-dir generated Hello.ice" />
    <Exec Condition="Exists('..\..\..\..\slice')" Command="..\..\..\..\cpp\bin\slice2cs.exe --output-dir generated Hello.ice" />
    </Target>

    in the .csproj fille, but I have not been able to find a way to edit or add this using project properties from VisualStudio. How did you do that??
    I manually edited the *.csproj files and added it. Not ideal, but it met our needs.

  9. #9
    sylvain is offline Registered User
    Name: Sylvain Fasel
    Organization: university of Geneva
    Project: quantum cryptographic systems
    Join Date
    Feb 2003
    Location
    Geneva (Switzerland)
    Posts
    42

    Red face

    I see, nice hack!

    I now understand why I had these warnings while opening the solution.

    You could basically run whatever you want using this tweak, frightening!

    Regards.
    Sylvain Fasel
    Group of Applied Physics
    University of Geneva
    www.gapoptic.unige.ch
    Research in applied quantum cryptography

  10. #10
    kwaclaw is offline Registered User
    Name: Karl Waclawek
    Organization: Personal
    Project: Whiteboard application
    Join Date
    Sep 2004
    Location
    Oshawa, Canada
    Posts
    159
    Quote Originally Posted by dwayne View Post
    I manually edited the *.csproj files and added it. Not ideal, but it met our needs.
    I played around with this approach and it seems the following recipe works also:

    1. Add your Slice files to a Visual Studio project and on their properties page assign them a custom Build Action name, e.g. "Slice".

    2. 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".

    3. Add this <Compile> item in the project file:
      Code:
        <ItemGroup>
          . . .
          <Compile Include="@(SliceGenerated)">
            <Visible>False</Visible>
          </Compile>
          . . .
        </ItemGroup>
      The <Visible>False</Visible> tag prevents double display in the Visual Studio IDE.

    4. 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&quot;..\slice&quot; --output-dir generated @(Slice->'&quot;%(Identity)&quot;', ' ')" />
        </Target>
        <Target Name="AfterClean">
          <Delete Files="@(SliceGenerated)" />
        </Target>
        <PropertyGroup>
          <CompileDependsOn>
            CompileSlice;$(CompileDependsOn)
          </CompileDependsOn>
        </PropertyGroup>
      This last step requires that ICE_HOME is a defined environment variable, and that the parameters for slice2cs are properly set, like include directories (-I) and output directories ( --output-dir).

    Karl
    Karl Waclawek

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 1
    Last Post: 10-01-2009, 10:49 PM
  2. Visual Studio Extension - Slice Compiler Options
    By domehead100 in forum Help Center
    Replies: 2
    Last Post: 07-31-2009, 01:38 PM
  3. Replies: 4
    Last Post: 02-28-2009, 10:20 AM
  4. Custom headers in generated files
    By Sameerrele in forum Help Center
    Replies: 2
    Last Post: 10-17-2006, 06:02 PM
  5. Visual Studio 6 project files for Ice
    By gmueckl in forum Help Center
    Replies: 2
    Last Post: 09-02-2003, 03:18 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •