Possible to remove and add a reference to csproj programmatically via a batch file?

后端 未结 2 1244
夕颜
夕颜 2020-12-21 16:05

I am writing a short batch file to prepare a control library DLL with Examples project for deployment via sip file and have the following question.

Given a csproj f

相关标签:
2条回答
  • 2020-12-21 16:10

    csproj files are XML files - you can easily write a command line application to manipulate these files (adding, removing nodes etc).

    You can call such a command line application from your batch file.

    You can find the schema for this file at:

    %windir%\Microsoft.NET\Framework\[framework version]\Microsoft.Build.xsd
    

    As described in this SO answer.

    0 讨论(0)
  • 2020-12-21 16:15

    I don't understand why you would need to modify the csproj file in your case. Just make sure the library reference in the csproj file is relative, i.e. ..\..\..\SDK\WPF\4.0\ControlLibrary.dll and it will keep working fine even if you move the complete folder hierarchy to a new location.

    If you're trying to simplify adding the library to new projects though, take a look at NuGet. It's the best way for distributing and deploying libraries.

    0 讨论(0)
提交回复
热议问题