Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"Include in Project" strange behavior for dataset in VisualStudio 2013

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?

like image 767
Aleksandr Ivanov Avatar asked Apr 13 '15 15:04

Aleksandr Ivanov


2 Answers

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.

like image 197
Brian G Avatar answered Nov 08 '22 07:11

Brian G


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.

like image 44
Shahzad Qureshi Avatar answered Nov 08 '22 05:11

Shahzad Qureshi