File tree Expand file tree Collapse file tree 2 files changed +24
-1
lines changed
src/Tools/dotnet-user-secrets Expand file tree Collapse file tree 2 files changed +24
-1
lines changed Original file line number Diff line number Diff line change 4
4
using System ;
5
5
using System . IO ;
6
6
using System . Linq ;
7
+ using System . Xml ;
7
8
using System . Xml . Linq ;
8
9
using System . Xml . XPath ;
9
10
using Microsoft . Extensions . CommandLineUtils ;
@@ -122,7 +123,16 @@ public void Execute(CommandContext context)
122
123
propertyGroup . Add ( new XElement ( "UserSecretsId" , newSecretsId ) ) ;
123
124
}
124
125
125
- projectDocument . Save ( projectPath ) ;
126
+ var settings = new XmlWriterSettings
127
+ {
128
+ Indent = true ,
129
+ OmitXmlDeclaration = true ,
130
+ } ;
131
+
132
+ using ( var xw = XmlWriter . Create ( projectPath , settings ) )
133
+ {
134
+ projectDocument . Save ( xw ) ;
135
+ }
126
136
127
137
context . Reporter . Output ( Resources . FormatMessage_SetUserSecretsIdForProject ( newSecretsId , projectPath ) ) ;
128
138
}
Original file line number Diff line number Diff line change 4
4
using System ;
5
5
using System . IO ;
6
6
using System . Text ;
7
+ using System . Xml . Linq ;
7
8
using Microsoft . AspNetCore . Testing ;
8
9
using Microsoft . Extensions . Configuration . UserSecrets . Tests ;
9
10
using Microsoft . Extensions . SecretManager . Tools . Internal ;
@@ -90,6 +91,18 @@ public void DoesNotGenerateIdForProjectWithSecretId()
90
91
Assert . Equal ( SecretId , idResolver . Resolve ( null , null ) ) ;
91
92
}
92
93
94
+ [ Fact ]
95
+ public void DoesNotAddXmlDeclarationToProject ( )
96
+ {
97
+ var projectDir = _fixture . CreateProject ( null ) ;
98
+ var projectFile = Path . Combine ( projectDir , "TestProject.csproj" ) ;
99
+
100
+ new InitCommand ( null , null ) . Execute ( MakeCommandContext ( ) , projectDir ) ;
101
+
102
+ var projectDocument = XDocument . Load ( projectFile ) ;
103
+ Assert . Null ( projectDocument . Declaration ) ;
104
+ }
105
+
93
106
[ Fact ]
94
107
public void OverridesIdForProjectWithSecretId ( )
95
108
{
You can’t perform that action at this time.
0 commit comments