Skip to content
Snippets Groups Projects
Commit 9bf211c7 authored by Bensong Liu's avatar Bensong Liu
Browse files

csproj25 bug fix

parent d59b24c9
No related branches found
No related tags found
Loading
......@@ -57,7 +57,7 @@ func main() {
// Good luck for old MacOS! They use single \r as newline.
lines := strings.Split(strings.ReplaceAll(string(content), "\r\n", "\n"), "\n")
resultTxt := ""
removeEndRefInNextLine := false // temporary variable, looks like a workaround.
removeEndOfTagInNextLine := "" // Empty value indicates no need to remove EOT.
for _, line := range lines {
// We assume that, there's at most one issue in every line.
// That's why this tool only works to well-formatted csproj, instead of any xml.
......@@ -65,8 +65,16 @@ func main() {
if stringContainsInsensitive(line, "<compile include=") {
if ! strings.Contains(line, "..") {
// Remove this line
continue
// Remove this <compile include>!
if strings.Contains(line, "/>") {
// Just remove this line
continue
} else {
// Remove until tag close
if removeEndOfTagInNextLine == "" {
removeEndOfTagInNextLine = "</compile>"
}
}
}
}
......@@ -99,18 +107,23 @@ func main() {
if stringContainsInsensitive(line, `"System.ValueTuple"`) || stringContainsInsensitive(line, `$(PkgSystem_ValueTuple)`) {
// Remove this line.
removeEndRefInNextLine = ! stringContainsInsensitive(line, "</Reference>")
if ! stringContainsInsensitive(line, "</Reference>") {
// We need to remove more lines...
if removeEndOfTagInNextLine == "" {
removeEndOfTagInNextLine = "</Reference>"
}
}
continue;
}
if removeEndRefInNextLine {
pos := stringIndexInsensitive(line, "</Reference>");
if removeEndOfTagInNextLine != "" {
pos := stringIndexInsensitive(line, removeEndOfTagInNextLine);
if pos == -1 {
// this line still not contains </Reference>
// Skip this line and keep checking next line.
continue
} else {
line = line[pos+len("</Reference>"):]
removeEndRefInNextLine = false
line = line[pos+len(removeEndOfTagInNextLine):]
removeEndOfTagInNextLine = ""
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment