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