Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7511299
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T23:30:33+00:00 2026-05-29T23:30:33+00:00

I am trying to work out if it is possible, when using a Custom

  • 0

I am trying to work out if it is possible, when using a Custom Tool in Visual Studio, to have a change in the contents of one file, trigger the Custom Tool of another.

My scenario is this:

In a Visual Studio C# project, I have an “master.xsd” xml schema which includes several other other xsd files. I am using the Xsd2Code Visual Studio Custom Tool to generate a .cs from the schema. This works fine when the master.xsd itself changes, but I would like the custom tool to run on the file master.xsd when one of the other xsds changes.

Is there any way of one file triggering another’s Custom Tool?

[EDIT – more detail on why I’m looking into using a custom tool for this]

At present we have a GenerateFiles.bat file that calls Xsd2Code from the command line to generate the code fiels from the schemas (as suggested by MattDavey below). This works, is just too slow.

The problem is that on every build Xsd2Code will, run but because lots of other projects depend on this project with the schemas, they will all recompile too even though probably nothing has changed. The practical upshot is that even a minor change to a unit test involves half the projects recompiling. This is why we’ve been looking at the custom tool approach to only generate the code files if the schema changes.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T23:30:35+00:00Added an answer on May 29, 2026 at 11:30 pm

    I use Xsd2Code a lot in this way, but my approach is to add a pre-build event which calls the Xsd2Code command line and regenerates the xml on each build..

    My pre-build event looks like this:

    $(ProjectDir)BuildTools\Xsd2Code.exe $(ProjectDir)Api\Schemas\MySchema.xsd MyProject.Api.Schemas $(ProjectDir)Api\Schemas\MySchema.cs /platform Net40 /collection Array  /sc+ /ap+ /if- /xa+
    

    In your case you could run this pre-build step only on the master xsd (which i’m guessing xsd:Imports the other schemas), or you could run the command on each of your schema files individually.

    The advantage for this is that, if I change the XSD schema, I get very useful compile time errors 🙂

    Hope that gives you some ideas!

    EDIT

    I spent some time thinking about the issue you highlighted regarding build time and modified the pre-build script like so:

    $(ProjectDir)BuildTools\Xsd2Code.exe $(ProjectDir)Api\Schemas\MySchema.xsd MyProject.Api.Schemas $(ProjectDir)Api\Schemas\MySchema.cs.temp /platform Net40 /collection Array  /sc+ /ap+ /if- /xa+
    
    fc $(ProjectDir)Api\Schemas\MySchema.cs  $(ProjectDir)Api\Schemas\MySchema.cs.temp
    
    if errorlevel 1 copy $(ProjectDir)Api\Schemas\MySchema.cs.temp $(ProjectDir)Api\Schemas\MySchema.cs /Y
    
    del $(ProjectDir)Api\Schemas\MySchema.cs.temp
    

    So Xsd2Code is now generating the source code into a temporary file, which is only overwriting the existing .cs file if it is different. This should mean that if the .xsd hasn’t changed at all, neither will the generated .cs 🙂

    You’re still taking the hit of running xsd2code, but you’re not taking the hit of msbuild rebuilding an entire chain of projects if the generated source was the same..

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to work out the format of a password file which is
I'm trying to work out if this is possible, let me give an example.
I have been trying to work out the bug on this but can't seem
I've been trying to work out whether it's possible to manage (i.e. add tables,
I'm stuck trying to work out the best possible way to approach this. Basically,
I have been trying to work out how to insert text before and after
I have found very little on this topic. I'm trying to work out a
I am trying work out with MERGE statment to Insert / Update Dimension Table
I am trying to work out the best database model for the current setup:
I am trying to work out how to get the value of table cell

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.