如何使用xml修改.csproj文件

时间:2022-08-15 00:31:32

my csproj file contain below itemgroup.

我的csproj文件包含在itemgroup下面。

  <ItemGroup>
    <Compile Include="Properties\AssemblyInfo.cs" />
  </ItemGroup>

i wanted to replace

我想替换

<Compile Include="Properties\AssemblyInfo.cs" /> //it have little bit space between Properties\AssemblyInfo.cs" and closing tag(/>)
To    
<Compile Include="Properties\AssemblyInfo.cs"/> //it have no space.

i don't want any space.how to achive it using XDocument linq.

我不想要任何space.how使用XDocument linq来实现它。

1 个解决方案

#1


0  

I guess I don't know why you would need to read a .csproj file for anything, but you can do a couple of things.

我想我不知道为什么你需要读取.csproj文件,但你可以做几件事。

  • You can just open up the file in NotePad and edit the space(s) out.
  • 您只需在NotePad中打开文件并编辑空格即可。

  • If Visual Studio puts the spaces back in, then maybe you can take the space out again and use a closing tag.

    如果Visual Studio将空格重新放入,那么也许您可以再次占用空间并使用结束标记。

    <ItemGroup>
    <Compile Include="Properties\AssemblyInfo.cs"></Compile>
    </ItemGroup>

Maybe I just don't get the question.

也许我只是不明白这个问题。

#1


0  

I guess I don't know why you would need to read a .csproj file for anything, but you can do a couple of things.

我想我不知道为什么你需要读取.csproj文件,但你可以做几件事。

  • You can just open up the file in NotePad and edit the space(s) out.
  • 您只需在NotePad中打开文件并编辑空格即可。

  • If Visual Studio puts the spaces back in, then maybe you can take the space out again and use a closing tag.

    如果Visual Studio将空格重新放入,那么也许您可以再次占用空间并使用结束标记。

    <ItemGroup>
    <Compile Include="Properties\AssemblyInfo.cs"></Compile>
    </ItemGroup>

Maybe I just don't get the question.

也许我只是不明白这个问题。