diff --git a/src/SourceLink.Common.UnitTests/GenerateSourceLinkFileTests.cs b/src/SourceLink.Common.UnitTests/GenerateSourceLinkFileTests.cs
index 50ecb7c9..92344217 100644
--- a/src/SourceLink.Common.UnitTests/GenerateSourceLinkFileTests.cs
+++ b/src/SourceLink.Common.UnitTests/GenerateSourceLinkFileTests.cs
@@ -40,7 +40,6 @@ public void Empty(bool noWarning)
AssertEx.AssertEqualToleratingWhitespaceDifferences(expectedOutput, engine.Log);
Assert.Null(task.SourceLink);
- Assert.Null(task.FileWrite);
}
[Theory]
@@ -73,7 +72,6 @@ public void NoRepositoryUrl(bool noWarning)
AssertEx.AssertEqualToleratingWhitespaceDifferences(expectedOutput, engine.Log);
Assert.Null(task.SourceLink);
- Assert.Null(task.FileWrite);
}
[Fact]
@@ -100,7 +98,6 @@ public void Empty_DeleteExistingFile()
string.Format(Resources.SourceLinkEmptyDeletingExistingFile, sourceLinkFile.Path), engine.Log);
Assert.Null(task.SourceLink);
- Assert.Equal(sourceLinkFile.Path, task.FileWrite);
}
[Fact]
@@ -235,7 +232,6 @@ public void DoesNotRewriteContentIfFileContentIsSame()
Assert.Equal(@"{""documents"":{""/_\""_/*"":""https://raw.githubusercontent.com/repo/*""}}", File.ReadAllText(tempFile.Path, Encoding.UTF8));
Assert.Equal(tempFile.Path, task.SourceLink);
- Assert.Equal(tempFile.Path, task.FileWrite);
result = task.Execute();
diff --git a/src/SourceLink.Common/GenerateSourceLinkFile.cs b/src/SourceLink.Common/GenerateSourceLinkFile.cs
index 8a076161..859cf0d6 100644
--- a/src/SourceLink.Common/GenerateSourceLinkFile.cs
+++ b/src/SourceLink.Common/GenerateSourceLinkFile.cs
@@ -21,12 +21,6 @@ public sealed class GenerateSourceLinkFile : Task
[Required, NotNull]
public string? OutputFile { get; set; }
- ///
- /// Set to if the output file was written to, null otherwise.
- ///
- [Output]
- public string? FileWrite { get; set; }
-
///
/// Set to if the output Source Link file should be passed to the compiler.
///
@@ -60,14 +54,14 @@ static string jsonEscape(string str)
if (!localPath.EndsWithSeparator())
{
- Log.LogError(Resources.MustEndWithDirectorySeparator, (isMapped ? Names.SourceRoot.MappedPathFullName : Names.SourceRoot.Name), localPath);
+ Log.LogError(Resources.MustEndWithDirectorySeparator, isMapped ? Names.SourceRoot.MappedPathFullName : Names.SourceRoot.Name, localPath);
success = false;
continue;
}
if (localPath.Contains('*'))
{
- Log.LogError(Resources.MustNotContainWildcard, (isMapped ? Names.SourceRoot.MappedPathFullName : Names.SourceRoot.Name), localPath);
+ Log.LogError(Resources.MustNotContainWildcard, isMapped ? Names.SourceRoot.MappedPathFullName : Names.SourceRoot.Name, localPath);
success = false;
continue;
}
@@ -127,7 +121,6 @@ private void WriteSourceLinkFile(string? content)
Log.LogMessage(Resources.SourceLinkEmptyDeletingExistingFile, OutputFile);
File.Delete(OutputFile);
- FileWrite = OutputFile;
return;
}
@@ -151,14 +144,11 @@ private void WriteSourceLinkFile(string? content)
Log.LogMessage(Resources.SourceLinkFileUpdated, OutputFile);
File.WriteAllText(OutputFile, content);
- FileWrite = SourceLink = OutputFile;
+ SourceLink = OutputFile;
}
catch (Exception e)
{
Log.LogError(Resources.ErrorWritingToSourceLinkFile, OutputFile, e.Message);
-
- // Part of the file might have been written.
- FileWrite = OutputFile;
}
}
}
diff --git a/src/SourceLink.Common/build/Microsoft.SourceLink.Common.targets b/src/SourceLink.Common/build/Microsoft.SourceLink.Common.targets
index ea05b196..0f9a8613 100644
--- a/src/SourceLink.Common/build/Microsoft.SourceLink.Common.targets
+++ b/src/SourceLink.Common/build/Microsoft.SourceLink.Common.targets
@@ -58,11 +58,16 @@
-
-
-
+
+
+
+
+
diff --git a/src/SourceLink.Git.IntegrationTests/CloudHostedProvidersTests.cs b/src/SourceLink.Git.IntegrationTests/CloudHostedProvidersTests.cs
index 8a91a9a3..58129d0b 100644
--- a/src/SourceLink.Git.IntegrationTests/CloudHostedProvidersTests.cs
+++ b/src/SourceLink.Git.IntegrationTests/CloudHostedProvidersTests.cs
@@ -131,6 +131,11 @@ public void NoCommit_NoRemote_NoWarnings()
+
+
+ <_SourceLinkFileWrites Include="@(FileWrites)" Condition="$([MSBuild]::ValueOrDefault('%(Identity)', '').EndsWith('sourcelink.json'))"/>
+
+
""",
customTargets: "",
targets: new[]
@@ -141,11 +146,13 @@ public void NoCommit_NoRemote_NoWarnings()
{
"@(SourceRoot)",
"$(SourceLink)",
+ "@(_SourceLinkFileWrites)",
},
expectedResults: new[]
{
NuGetPackageFolders,
"",
+ "",
});
}
@@ -160,6 +167,11 @@ public void Commit_NoRemote_NoWarnings()
+
+
+ <_SourceLinkFileWrites Include="@(FileWrites)" Condition="$([MSBuild]::ValueOrDefault('%(Identity)', '').EndsWith('sourcelink.json'))"/>
+
+
""",
customTargets: "",
targets: new[]
@@ -170,12 +182,14 @@ public void Commit_NoRemote_NoWarnings()
{
"@(SourceRoot)",
"$(SourceLink)",
+ "@(_SourceLinkFileWrites)",
},
expectedResults: new[]
{
NuGetPackageFolders,
ProjectSourceRoot,
"",
+ "",
});
}
@@ -190,6 +204,11 @@ public void NoCommit_Remote_NoWarnings()
+
+
+ <_SourceLinkFileWrites Include="@(FileWrites)" Condition="$([MSBuild]::ValueOrDefault('%(Identity)', '').EndsWith('sourcelink.json'))"/>
+
+
""",
customTargets: "",
targets: new[]
@@ -200,11 +219,13 @@ public void NoCommit_Remote_NoWarnings()
{
"@(SourceRoot)",
"$(SourceLink)",
+ "@(_SourceLinkFileWrites)",
},
expectedResults: new[]
{
NuGetPackageFolders,
"",
+ "",
});
}
@@ -230,21 +251,27 @@ public void CustomTranslation()
DependsOnTargets=""$(SourceControlManagerUrlTranslationTargets)""
BeforeTargets=""SourceControlManagerPublishTranslatedUrls"">
-
- <_Pattern>https://([^.]+)[.]visualstudio.com/([^/]+)/_git/([^/]+)
- <_Replacement>https://github.com/$2/$3
-
-
-
- $([System.Text.RegularExpressions.Regex]::Replace($(ScmRepositoryUrl), $(_Pattern), $(_Replacement)))
-
-
-
-
- $([System.Text.RegularExpressions.Regex]::Replace(%(SourceRoot.ScmRepositoryUrl), $(_Pattern), $(_Replacement)))
-
-
-
+
+ <_Pattern>https://([^.]+)[.]visualstudio.com/([^/]+)/_git/([^/]+)
+ <_Replacement>https://github.com/$2/$3
+
+
+
+ $([System.Text.RegularExpressions.Regex]::Replace($(ScmRepositoryUrl), $(_Pattern), $(_Replacement)))
+
+
+
+
+ $([System.Text.RegularExpressions.Regex]::Replace(%(SourceRoot.ScmRepositoryUrl), $(_Pattern), $(_Replacement)))
+
+
+
+
+
+
+ <_SourceLinkFileWrites Include=""@(FileWrites)"" Condition=""$([MSBuild]::ValueOrDefault('%(Identity)', '').EndsWith('sourcelink.json'))""/>
+
+
",
targets: new[]
{
@@ -256,7 +283,8 @@ public void CustomTranslation()
"@(SourceRoot->'%(SourceLinkUrl)')",
"$(SourceLink)",
"$(PrivateRepositoryUrl)",
- "$(RepositoryUrl)"
+ "$(RepositoryUrl)",
+ "@(_SourceLinkFileWrites)",
},
expectedResults: new[]
{
@@ -266,6 +294,7 @@ public void CustomTranslation()
s_relativeSourceLinkJsonPath,
$"https://github.com/test-org/{repoName}",
$"https://github.com/test-org/{repoName}",
+ s_relativeSourceLinkJsonPath
});
AssertEx.AreEqual(