Indentation on .csproj breaks the build
See original GitHub issueIndentation breaks the .csproj file.
Error:
dotnet build DoesntWorks.csproj
Microsoft (R) Build Engine version 15.7.177.53362 for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.
Restore completed in 40.4 ms for /Users/dario/src/core-dal/src/CoreViejo/DoesntWorks.csproj.
/usr/local/share/dotnet/sdk/2.1.200/Sdks/Microsoft.NET.Sdk/build/Microsoft.NET.TargetFrameworkInference.targets(96,5): error : The TargetFramework value 'netcoreapp2.0' was not recognized. It may be misspelled. If not, then the TargetFrameworkIdentifier and/or TargetFrameworkVersion properties must be specified explicitly. [/Users/dario/src/core-dal/src/CoreViejo/DoesntWorks.csproj]
Build FAILED.
/usr/local/share/dotnet/sdk/2.1.200/Sdks/Microsoft.NET.Sdk/build/Microsoft.NET.TargetFrameworkInference.targets(96,5): error : The TargetFramework value 'netcoreapp2.0' was not recognized. It may be misspelled. If not, then the TargetFrameworkIdentifier and/or TargetFrameworkVersion properties must be specified explicitly. [/Users/dario/src/core-dal/src/CoreViejo/DoesntWorks.csproj]
0 Warning(s)
1 Error(s)
Time Elapsed 00:00:01.06
File that works:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
</PropertyGroup>
</Project>
Indented file that doesn’t works:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>
netcoreapp2.0
</TargetFramework>
</PropertyGroup>
</Project>
Solution: Disabling indentation tool on Visual Studio Code for .csproj files.
My dotnet --info
:
.NET Command Line Tools (2.1.200)
Product Information:
Version: 2.1.200
Commit SHA-1 hash: 2edba8d7f1
Runtime Environment:
OS Name: Mac OS X
OS Version: 10.13
OS Platform: Darwin
RID: osx.10.13-x64
Base Path: /usr/local/share/dotnet/sdk/2.1.200/
Microsoft .NET Core Shared Framework Host
Version : 2.0.7
Build : 2d61d0b043915bc948ebf98836fefe9ba942be11
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
Visual Studio web csproj file indenting flipping between ...
The indentation of our web .csproj file is being changed to spaces or tabs, depending on the particular installation/user/machine doing the ...
Read more >csproj files initially display wrong indent
Create a new .NET Core C# project called TestIndent. * Open the .csproj file by right clicking on the project in Solution Explorer...
Read more >Copy with proper indentation - Visual Studio Blog
You want to share some code you've written with a colleague, so you select it in the editor and hit Ctrl + C...
Read more >Solution files are a nightmare that has to disappear and ...
Solution files provide accurate control over projects, build configs, ... Impossible to edit large files because it's indentation sensitive.
Read more >What setting in visual studio forces indentation on new line ...
What I would like is for a new line to come down to the same indentation, so that I can place my curly...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I don’t believe the problem here is the indentation but the newlines in the target framework value.
The proper title is
Whitespace is not being trimmed
This is far simpler than this discussion indicates. Normally leading and trailing whitespace is ignored in HTML and XML. Simply observing that convention solves the problem. The bug is not that the build fails, the bug is that whitespace is significant.
I was amused by http://usingxml.com/Basics/XmlSpace which complained that the default Microsoft parse trims whitespace.
There are no newlines, indentations, or whatever. There is just whitespace that is to be trimmed.