Found so many people asking the question. Let me share the way of using LINQ to XSD(No Need to use the Command Prompt )!!!!!!!!

Dec 16, 2010 at 7:24 AM

1. Creat a 'Visual Studio 2008(2010)' project.
2. create a directory that will contain your LinqToXsd binaries (e.g. 
$(SolutionDir)\..\Resources\LinqToXSD). note: this forld contains the 
binaries of LinqToXSD
3.On the property page of your created project, select the Build Events 
tag, and in the prebuild event command line, Type 'SET LINQTOXSDBINDIR=
$(SolutionDir)\..\Resources\LinqToXSD' (replace with the path you have 
chosen from 2.)4. Before you can use the build tasks, you have to prepare your project 
file. Right click the project in Solution Explorer at select 'Unload 
Project'. 
5. Right click the project (unloaded) again and select 'Edit 
[YourProjectFileName].csproj'. The project file will be opened in the 
Visual Studio XML text editor. 
6. Navigate to the end of the file. Now add the following lines into the 
project file below the last 'PropertyGroup':

<PropertyGroup>   <LinqToXsdBinDir Condition="'$(LinqToXsdBinDir)' == ''">$(SolutionDir)
</LinqToXsdBinDir></PropertyGroup>

7. Now navigate to the very end of the file below the very last and insert 
the following lines after the very last 'Import'. Enter the following 
line. It is very important that this line is located after all other 
import statements.

<Import Project="$(LinqToXsdBinDir)\LinqToXsd.targets" />
8. Right click your project and select 'Reload Project.
9. Finally, just change the build options for your XSD file. Open XSD file 
properties from the Solution Explorer, and change the Build action to 
LinqToXSDSchema.

refferences:
old example on codeproject:http://www.codeproject.com/KB/linq/LINQ_to_XSD.aspx
how to installhttp://linqtoxsd.codeplex.com/Thread/View.aspx?ThreadId=204476

Mar 1, 2011 at 11:31 AM

Didn't work for me, got "illegal characters in path" on the import targets statement.

Also it doesn't seem to pickup the LinqToXsdBinDir variable because it's looking for the targets file in the solutiondir root.

Best regards

Mar 1, 2011 at 11:37 AM
Edited Mar 1, 2011 at 11:38 AM

For a solution arranged with a folder containing LinqToXsd parallel in the hierarchy to the project folders and the solution files inside the project folders.

We just use:

<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5">
  <PropertyGroup>
    <LinqToXsdBinDir Condition="'$(LinqToXsdBinDir)' == ''">$(SolutionDir)\..\linqtoxsd</LinqToXsdBinDir>

....rest of group

</PropertyGroup>

Then immediately after this line:

  <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />

We add:

  <Import Project="$(LinqToXsdBinDir)\LinqToXsd.targets" />

Regards,

James.

Mar 22, 2011 at 12:13 AM

I've followed these instructions and can now select the build action on the xsd as LinqToXSDSchema but when I build, everything seems to be written to folder obj/x86/debug including my WindowsFormsApplication1.exe/pdb. And, the name of my linq-to-xsd file is LinqToXsdSource.cs which is going to be worthless if I have to do this with more than one file. There must be more to configuring this or I've configured something wrong. Thanks!

Mar 22, 2011 at 12:39 PM

LinqToXsdSource.cs contains the source for every Xsd marked as LinqToXSDSchema.

So using more that one Xsd works just fine.

Sorry, I have no idea about the other bit.

James.

Mar 22, 2011 at 3:13 PM

We had the same problem. See: http://linqtoxsd.codeplex.com/workitem/6305 for a fix.

Mar 22, 2011 at 6:58 PM
Edited Mar 23, 2011 at 7:01 PM

JVennix - that worked great, thanks for all the help

Mar 23, 2011 at 7:14 PM

Is there a way to control the output namespace? I have the file names being appended with the source filename but the name space is the same so I still get dupicate definitions. Thanks!

Mar 23, 2011 at 9:27 PM

Set the target namespace of your Xsd.

<xs:schema xmlns="http://this.is.the.dot.net.namespace" xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="this.is.the.dot.net.namespace" elementFormDefault="qualified" attributeFormDefault="unqualified" id="Types">

James.

Mar 23, 2011 at 10:13 PM

Thanks, I should have said w/o changing the target namespace but if there is no other way I can work around it. Thanks again.

Mar 24, 2011 at 9:13 AM

There is no default way to do this. We have built it in in our private version, but it still dodgy. (Dodgy enough that it doesn't work properly yet).

Apr 5, 2011 at 2:33 AM
roboj1m wrote:

Set the target namespace of your Xsd.

<xs:schema xmlns="http://this.is.the.dot.net.namespace" xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="this.is.the.dot.net.namespace" elementFormDefault="qualified" attributeFormDefault="unqualified" id="Types">

James.

yes there is :

create an XML file in the same solution as your XSD and ( call it linq2xsdconfig.xml) 

edit the file so that it reads.

<?xml version="1.0" encoding="utf-8" ?>
<Configuration xmlns="http://www.microsoft.com/xml/schema/linq">
	<Namespaces>
		<Namespace Schema="http://yourxsdnamespace" Clr="MyProject.MyNameSpace"/>
	</Namespaces>
</Configuration>

Select the build action of the  linq2xsdconfig.xml to : LinqToXsdConfiguration

 

 

Apr 5, 2011 at 2:34 AM
kthorne wrote:

Is there a way to control the output namespace? I have the file names being appended with the source filename but the name space is the same so I still get dupicate definitions. Thanks!

 

yes there is :

create an XML file in the same solution as your XSD and ( call it linq2xsdconfig.xml) 

edit the file so that it reads.

<?xml version="1.0" encoding="utf-8" ?>
<Configuration xmlns="http://www.microsoft.com/xml/schema/linq">
	<Namespaces>
		<Namespace Schema="http://yourxsdnamespace" Clr="MyProject.MyNameSpace"/>
	</Namespaces>
</Configuration>

Select the build action of the  linq2xsdconfig.xml to : LinqToXsdConfiguration

Apr 5, 2011 at 2:38 AM

you could also simplify this by using an Environment variable ...

https://resources.riskfocusinc.com/portal/display/PUBLIC/Using+LINQTOXSD+to+process+FpML

Sep 8, 2011 at 12:44 PM
echosong wrote:

3.On the property page of your created project, select the Build Events 
tag, and in the prebuild event command line, Type 'SET LINQTOXSDBINDIR=
$(SolutionDir)\..\Resources\LinqToXSD' (replace with the path you have 
chosen from 2.)

I have now for a long time tried to set path to LinqToXSD bins to the environment variable in the pre build event, but I can't get it to work. The reason is that when you set the environment variable during pre build step it's alive just in that context. When pre build event finishes the environment variable is gone.

I really want to find a solution where I don't need to set a environment variable in System Properties to get it working.

Any suggestions?

Sep 8, 2011 at 2:26 PM

create a batch file in which you set the variable and from there launch visual studio, two lines. You can even give the batch file the same icon as visual studio. This is what I've done below. I've used LINQToXSD to generate large complex reports and with some minor exceptions it's worked really well.

SET LINQTOXSDBINDIR=c:\LinqToXSDBin
devenv

 

Sep 8, 2011 at 3:26 PM
kthorne wrote:

create a batch file in which you set the variable and from there launch visual studio, two lines. You can even give the batch file the same icon as visual studio. This is what I've done below. I've used LINQToXSD to generate large complex reports and with some minor exceptions it's worked really well.

SET LINQTOXSDBINDIR=c:\LinqToXSDBin
devenv

 

Yes I could do it like that, but I want our XSD project to be "self contained". The reason for this is that we are a number of people in our project, people come and go (consultance) and the less custom setup needed the better.

Sep 9, 2011 at 9:32 PM
Edited Sep 9, 2011 at 9:33 PM

I simply can't believe it!

This project is likely gonna die a slow death just because nobody(most importantly newbies) knows how to set it up & use it.

Where has the notion of a streamlined installer from previous versions(eg. Alpha refresh off the MicroSoft downloads site) that sorted all of this out gone?

After waiting over a year for just 1 single working example on the .Net 4.0 version + listening to you guys, I still don't have a clue?

Please don't cop-out again by telling everyone to just fix it & be kind to us mere blue-collar mortals: please give a good walkthrough on setting it up and using it for the 1st time .

If YOU are really interested in keeping this cool tool alive, do give us that much.(Note: we aren't asking for Docs in a formal sense, just a working example of it's setup and use)

Adoption and prolifiration won't ever come to pass if the barrier to entry is higher and steeper than the North side of the Eiger.

Thanx for your efforts all the same, later ...

 

Sep 9, 2011 at 10:12 PM
Edited Sep 9, 2011 at 10:17 PM

LINQ To XSD has a great potential, therefor it's sad to see that there's so little talk around here.

I have tried different XSD code generation tools out there and found out that LINQ To XSD gave the best result for our project.

I also like the approach where the classes are auto generated based on the XSD (with the custom build action).

Up to now we have generated the classes with the command tool, but I have now set up a project up where I can use the LinqToXSDSchema build action for generating classes. We have some nasty namespaces in our XSDs and I have fixed that with the LinqToXsdConfiguration build action. This works perfectly and is a elegant way to deal with XSDs  (besides that environment variable we have to set).

 

I noticed something and I'm not sure what's going on, but I see that Sergey (developer on LINQ To XSD) has created http://openlinqtoxsd.codeplex.com/

The project description says "It is a fork of LINQ to XSD. The project is open for contributions."

Can someone tell us the reason for branching LINQ To XSD to a other project? Are there any constraints to work further on LINQ  To XSD?

Sep 10, 2011 at 10:52 PM

I don't have a solution for you regarding the necessary per-build variable. I have a separate project I use just to generate the LINQtoXSD files which I then move into my main project. I can't use the files exactly as they are generated because I have to use many of these files and the namespaces collide. I've also had to make minor modifications to some of the generated classes. Bottom line is, I don't really auto-generate them when I build. I too had the problem you have when I first started using LINQtoXSD but eventually settled with what I have now. Sorry I can't be of more help here.

Regarding getting LINQtoXSD working the first time, I had to muddle through it too. But if you edit your project file correctly and get the environment variable correct it will work. You might try getting through one step at a time and coming back here for help. I'm no expert but I have been using it heavily for the past 4 months. I've actually "re-documented" how this is set up for my client. If you like, I could send you that document, just send me your email address and I'll be happy to provide you with that. It's a bit of a pain to get it to work the first time; but, it works amazingly well once you do get it working and I'm pretty sure my application of it is unconventional making it even more impressive. Good luck and hang in there.

Sep 11, 2011 at 12:56 PM
I can enlighten you on that. Sergey started the fork because MS wasn't cooperating in bringing the project back alive. We decided to fork it in a discussion between the two of us, however until now we both haven't worked on forking it, because lack of time (at least from my side) and probably also from his.

 

owangen wrote:

LINQ To XSD has a great potential, therefor it's sad to see that there's so little talk around here.

I have tried different XSD code generation tools out there and found out that LINQ To XSD gave the best result for our project.

I also like the approach where the classes are auto generated based on the XSD (with the custom build action).

Up to now we have generated the classes with the command tool, but I have now set up a project up where I can use the LinqToXSDSchema build action for generating classes. We have some nasty namespaces in our XSDs and I have fixed that with the LinqToXsdConfiguration build action. This works perfectly and is a elegant way to deal with XSDs  (besides that environment variable we have to set).

 

I noticed something and I'm not sure what's going on, but I see that Sergey (developer on LINQ To XSD) has created http://openlinqtoxsd.codeplex.com/

The project description says "It is a fork of LINQ to XSD. The project is open for contributions."

Can someone tell us the reason for branching LINQ To XSD to a other project? Are there any constraints to work further on LINQ  To XSD?

 

 

Sep 11, 2011 at 10:54 PM
JVennix wrote:
I can enlighten you on that. Sergey started the fork because MS wasn't cooperating in bringing the project back alive. We decided to fork it in a discussion between the two of us, however until now we both haven't worked on forking it, because lack of time (at least from my side) and probably also from his.

 

That was what I suspected :-) Great too see you took the responsibility to fork it.

Looking forward to the release on Open LINQ To XSD.

Sep 12, 2011 at 11:24 AM

Is there any plans to support .NET 3.5 in OpenLinqToXsd?

Sep 13, 2011 at 8:38 PM
roboj1m wrote:

Is there any plans to support .NET 3.5 in OpenLinqToXsd?


There aren''t any plans at all at this moment, but what is the hold back for you to convert it back to 3.5 from 4.0?

Sep 15, 2011 at 2:48 PM

hehehe, money...

Actually I'm assured our new MSDN subscriptions have been approved and they are in the process of being procured.

Once that's done I'm moving everybody up to 2010.

Oct 4, 2011 at 9:55 AM

I followed the steps in the start of this post and it worked fine.

The trick to get the namespace right also works fine from the first try.

Thx for the info and lib, it saved me some days of 'entity creation'!