In NAnt, can I create a set of files from the files listed in the VS project?

I am rewriting NAnt scripts to make them cleaner and simpler, as well as more general purpose.

One of the steps in our build process is to pack certain files into a zip file. Before we created filesetwith a lot of file types included, trying to catch everything that might be in the project. This sometimes caused problems when we wanted to include a non-standard file type in the project.

I was hoping I could find a way to create filesetfile-based (as well as subsets of the files) listed in the Visual Studio project file (.csproj). Then I could use this set of files in zip. I did not find anything that does this automatically (although now the obsolete SLiNgshoTtask in NAntContrib looked a bit promising).

I started out on the road, trying to do it manually, but got stuck. I have a goal that gets the project from the solution (using regex), then tries to get every content file in the project using xmlpeek(with XPath request /n:Project/n:ItemGroup/n:Content/@Include). The problem here is that xmlpeekeach value does not return, just the first. And even if he really returned every value, I’m not sure how this can be done from filesethere.

Is there a way to save this track of thinking? Can I accomplish what I want with a custom NAnt task (I would prefer each project not to depend on a custom task)? Is there a built-in way to do this that I cannot find?

Please feel free to ask questions in the comments if something about my purpose or method is not clear.

Thanks!


: , , . .xml , .xml , , . , ( ), , . , , , . , ...

+3
3

. microsoft.build.buildengine , , , , .

, , , - , script. , , , , , ( Nant, , - ).

+2

. - . , , .

. , .

, Zip , , .

, - :

<fileset id="project.source.objects">
  <include name="**/*.cs"/>
  <include name="**/*.xml"/>
  <include name="**/*.resx"/>
</fileset>

<fileset id="project.misc.sources">
  <include name="MyFile1.someext"/>
</fileset>

:

<zip zipfile="myzip.zip">
  <fileset refid="project.source.objects"/>
  <fileset refid="project.misc.sources"/>
</zip>

, . , . VS2005 T4. , , - . , XSD ( , ).

, , . , , .

, . , .

+1

.

Write a small console application to pull files from .csproj (since it's just XML) and write the list to a file.

Instead of the NAnt zip task, I would use 7-zip to create an archive with the list generated in the previous step:

(here I create an archive of self-extracting archive)

<target name="ZipBuild">
  <exec program="${SevenZip}" workingdir="${SolutionPath}/Installation/Build.Staging">
    <arg value="a" />
    <arg value="-sfx" />
    <arg value="ReferenceBuild-${build.number}.exe" />
    <arg value="@mycustomfilelist.txt" />
  </exec>
</target>

Hope this helps,

Jason

0
source

Source: https://habr.com/ru/post/1702930/


All Articles