13

I want to do a very simple thing: move some code in VS13 from one project in to another one and I'm facing the strange problem with datasets. For simplicity let's say that in my source project I have one dataset named MyDataSet which consists from 5 files: MyDataSet.cs, MyDataSet.Designer.cs, MyDataSet.xsc, MyDataSet.xsd, MyDataSet.xss.

Then I copy these files to my destination project folder using standard windows functionality and use Include in Project menu option in VS13. After that I see that one extra file was added: MyDataSet1.Designer.cs.

I tried to check cproj files and they are different.

Source (only parts different from target are shown):

<Compile Include="MyDataSet.Designer.cs">
  <AutoGen>True</AutoGen>
  <DesignTime>True</DesignTime>
  <DependentUpon>MyDataSet.xsd</DependentUpon>
</Compile>

<None Include="MyDataSet.xsd">
  <SubType>Designer</SubType>
  <Generator>MSDataSetGenerator</Generator>
  <LastGenOutput>MyDataSet.Designer.cs</LastGenOutput>
</None>

Target (only part different from source are shown):

<Compile Include="MyDataSet.Designer.cs">
  <DependentUpon>MyDataSet.cs</DependentUpon>
</Compile>

<Compile Include="MyDataSet1.Designer.cs">
  <AutoGen>True</AutoGen>
  <DesignTime>True</DesignTime>
  <DependentUpon>MyDataSet.xsd</DependentUpon>
</Compile>

<None Include="MyDataSet.xsd">
  <Generator>MSDataSetGenerator</Generator>
  <LastGenOutput>MyDataSet1.Designer.cs</LastGenOutput>
  <SubType>Designer</SubType>
</None>

Also I noticed that in MyDataSet.cs and MyDataSet1.Designer.cs namespaces were automatically changed to correct ones.

I'm using ReSharper, and first I thought that it can be a reason of that, but I disabled ReSharper and the same behavior continues to happen.

Probably I can fix that by removing newly created files and modifying cproj files, but actually there are a lot of datasets that I need to copy and I really don't like that kind of work.

Does anyone have any ideas what can be a reason of such problem and how can it be solved?

Community
  • 1
  • 1
Aleksandr Ivanov
  • 2,778
  • 5
  • 27
  • 35
  • When you Include In Project are you just including the MyDataSet.cs, or all of the files? – ZaXa Apr 15 '15 at 18:34
  • Yes, I include all 5 files. – Aleksandr Ivanov Apr 15 '15 at 18:38
  • That may be your problem. Just include the MyDataSet.cs and it usually finds the rest on its own. I've had similar issues when moving Forms between projects and that was the answer. – ZaXa Apr 15 '15 at 18:57
  • @ZaXa, unfortunately this doesn't help. When I click `Show All Files` to be able to include files in project, I don't see them as separate files but they are already structured. So I can't add individual dataset files. – Aleksandr Ivanov Apr 15 '15 at 19:49
  • When you copied your files over where they readonly? – Matt Johnson Apr 15 '15 at 21:23
  • I'm not sure about "Include In Project". I've always used "Add Existing Items". Then I double click the root .cs file, and it pulls in the dependencies for me. – ZaXa Apr 15 '15 at 22:39

2 Answers2

5

Move the dataset from within Visual Studio by right-clicking the dataset root node in Solution Explorer (usually the .xsd) and selecting Copy, and then right-click the destination project or project folder and select Paste. This should copy the files and correctly markup the csproj files.

Brian G
  • 233
  • 2
  • 6
  • The problem is that source dataset is in SVN and I'm copying files using SVN functionality to keep files history. I'm afraid if I do it your way history will be lost. – Aleksandr Ivanov Apr 15 '15 at 21:34
  • Do it both ways, so you can keep the source control history. I haven't used SVN in a while, but in git or TFS this works - checkout, move in Visual Studio to get the csproj correct, then move the files using the source control system to get the history correct, and once you are happy that both are moved you can checkin. You may have to undo the Visual Studio moves using the file system to let source control pretend that it is in charge, but Visual Studio will not mind as long as the files end up in the right place. – Brian G Apr 15 '15 at 22:11
  • Depending on the SVN you are using you might also be able to use [Repair Move](http://codeclimber.net.nz/archive/2010/01/11/tortoise-svn-tip-repair-move.aspx) or something like it. – Brian G Apr 15 '15 at 22:18
  • I think move trick might work. And thank you for getting know about "Repair Move" feature. – Aleksandr Ivanov Apr 15 '15 at 23:00
  • It seems that this is the easiest way to copy datasets. – Aleksandr Ivanov Apr 23 '15 at 14:52
2

Copy the files using windows functionality like you did. However, instead of using "Include in Project" manually edit the new .csproj file in notepad to include the lines exactly as it appears in the old .csproj file. Then when your project refreshes you should be all set.

Shahzad Qureshi
  • 1,776
  • 14
  • 15
  • This is almost what I did. But when you need to copy 30 datasets, it's takes a lot of time ans is error prone. So I wonder if there a better way to do it. – Aleksandr Ivanov Apr 20 '15 at 17:37