Class: CrossPlatformCSProj

Inherits:
Object
  • Object
show all
Defined in:
lib/cross_platform_csproj.rb

Class Method Summary collapse

Class Method Details

.updateProject(projectFile, fileList) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/cross_platform_csproj.rb', line 5

def self.updateProject(projectFile, fileList)
	if !File.exists?(projectFile)
		puts "CSProject file does not point to any file: #{projectFile}" 
	end

	for file in fileList do
		if !File.exists?(file)
			puts "A file in the in the file list is not a valid file: #{fileList}"
		end
	end

	rootPath = File.dirname(projectFile).gsub('/', '\\')
	document = openDocument(projectFile)
	parent = getParentNode(document)

	if parent != nil
		parent.children.remove

		for file in fileList do
			compileNode = Nokogiri::XML::Node.new 'Compile', document

			parent.add_child(compileNode)

			relativeFile = getRelativePath(file, rootPath)

			compileNode.set_attribute('Include', relativeFile)
		end
	end

	saveDocument(document, projectFile)
end