none
"Custom Tool" file property unavailable in shared projects?

    Question

  • I'm using Visual Studio 2013 to build a multiplatform Xamarin application, using a hybrid webview and Razor templates for the user interface. The *.cshtml files containing the templates are in a portable class library, and each template has its "Custom Tool" property set to "RazorTemplatePreprocessor" (a MonoDevelop tool) in order for the corresponding C# classes to be generated when the files are saved.



    I've seen this question asked in a few places, so I feel the need to stress that this is not a custom build tool or a build step, it's a file property that defines a tool to run on the file at design time.

    In order to resolve some tangled multiple-dependency issues with my UI, I want to move my Razor templates into a shared project instead of a PCL. However, files in a shared project don't seem to have a "Custom Tool" field in their file properties, so no C# classes are generated and thus they're unusable.



    I initially assumed this was just a missing field in the VS2013 interface, so the first thing I tried was opening the *.projitems file for the shared project and pasting in the relevant data from the *.csproj for the PCL version (with "$(MSBuildThisFileDirectory)" added to comply with shared project syntax):

      <ItemGroup>
        <Compile Include="$(MSBuildThisFileDirectory)RazorView.cs">
          <DependentUpon>RazorView.cshtml</DependentUpon>
          <AutoGen>True</AutoGen>
          <DesignTime>True</DesignTime>
        </Compile>
      </ItemGroup>
      <ItemGroup>
        <None Include="$(MSBuildThisFileDirectory)RazorView.cshtml">
          <Generator>RazorTemplatePreprocessor</Generator>
          <LastGenOutput>RazorView.cs</LastGenOutput>
        </None>
      </ItemGroup>

    ...but sadly this didn't work, it just added a reference to a nonexistent *.cs file without actually running the custom tool. :(

    Is there a workaround for this? Or do I have no choice but to rearchitect my solution so the templates can remain in a portable class library? Thanks!

    • Edited by GKokoris Wednesday, March 25, 2015 1:50 PM typo
    Wednesday, March 25, 2015 1:48 PM

Answers

All replies

  • Hi GKokoris,

    Thank you for posting in the MSDN forum.

    Since it is related to the specific multiplatform Xamarin applications, you know that actually it has his own supported forum, to really repro this issue, and make sure that whether the shared project supports the Custom tool, if possible, I suggest you post this issue to the Xamarin forum here:

    http://forums.xamarin.com/

    You could share the detailed steps/a simple sample in your new thread, so the Xamarin experts would really repro this issue one step by one step.

    But if we make sure that it doesn't support this feature for the specific shared projects, you could submit a feature request here:

    http://visualstudio.uservoice.com/forums/121579-visual-studio. The Visual Studio product team is listening to user voice there.

    Sincerely,

    Jack


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, March 26, 2015 9:42 AM
    Moderator
  • Hi Jack,

    Thank you for your reply! My apologies, I may have crossed a few wires in my description. This issue is appearing in Visual Studio 2013, not the Xamarin IDE.

    I am also not having any issues with the custom tool I'm using; I am literally unable to define a custom tool at design time in any shared project in Visual Studio. To confirm this, I created a simple console application, added a shared project to the solution with a plain text file in it, and the Custom Tool field still did not appear in the file's properties panel. The situation was the same for *.cs classes and any other file format I added to the shared project.

    I'm still unsure if this is a bug, or a deliberate design decision as part of the shared project spec in VS2013.

    Sorry, I know it's standard procedure to direct users elsewhere if there's a possibility a non-Microsoft product is causing an issue, but I've safely eliminated Xamarin as the source of the problem. I'll go ahead and submit a feature request at the link you posted.

    Thanks again!
    Thursday, March 26, 2015 10:12 AM
  • Hi GKokoris,

    Thanks for your friendly response.

    I think I could repro this issue, for example, if I create the universal app, it also has a shared project in the solution in default, if I add the .cshtml file in the shared project, it doesn't have the "custom tool" property.

    So I doubt that it would have this limitation, if you submit a user voice, please share me the link here, I will help you vote it.

    Best Regards,

    Jack


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, March 27, 2015 1:50 AM
    Moderator
  • Monday, March 30, 2015 3:13 PM
  • Vote it!

    Have a nice day,

    Jack


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, March 31, 2015 1:53 AM
    Moderator