Skip to content

Commit

Permalink
Sets an encoding for workspace source text (#128)
Browse files Browse the repository at this point in the history
  • Loading branch information
daveaglick committed Dec 23, 2021
1 parent ba22694 commit 325949a
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 18 deletions.
4 changes: 4 additions & 0 deletions ReleaseNotes.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 3.2.6

- Specifies an encoding for source text in `Buildalyzer.Workspaces` to avoid CS8055 errors ("Cannot emit debug information for a source text without encoding") when compiling the workspace (#128).

# 3.2.5

- Added a strongly-typed `PreprocessorSymbols` collection to `AnalyzerResults` and used it to flow constants through to `Buildalyzer.Workspaces` for .NET 5 and up projects (#191, #192, thanks @richardwerkman).
Expand Down
34 changes: 17 additions & 17 deletions build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ Task("Restore")
.Description("Restores all NuGet packages.")
.IsDependentOn("Clean")
.Does(() =>
{
{
DotNetCoreRestore($"./{projectName}.sln", new DotNetCoreRestoreSettings
{
MSBuildSettings = msBuildSettings
Expand Down Expand Up @@ -119,7 +119,7 @@ Task("Test")
DotNetCoreTest(MakeAbsolute(project).ToString(), testSettings);
})
.DeferOnError();

Task("Pack")
.Description("Packs the NuGet packages.")
.IsDependentOn("Build")
Expand All @@ -128,10 +128,10 @@ Task("Pack")
DotNetCorePackSettings packSettings = new DotNetCorePackSettings
{
Configuration = configuration,
OutputDirectory = buildDir,
OutputDirectory = buildDir,
MSBuildSettings = msBuildSettings
};
foreach (var project in GetFiles("./src/*/*.csproj"))
{
DotNetCorePack(MakeAbsolute(project).ToString(), packSettings);
Expand All @@ -152,25 +152,25 @@ Task("Sign")
foreach (var nupkg in GetFiles($"{ buildDir }/*.nupkg"))
{
StartProcess("nuget", "sign \"" + nupkg.ToString() + "\" -CertificatePath \"davidglick.pfx\" -CertificatePassword \"" + certPass + "\" -Timestamper \"http://timestamp.digicert.com\" -NonInteractive");
}
}
});

Task("Zip")
.Description("Zips the build output.")
.IsDependentOn("Build")
.Does(() =>
{
{
foreach(var projectDir in GetDirectories("./src/*"))
{
CopyFiles(new FilePath[] { "LICENSE", "README.md", "ReleaseNotes.md" }, $"{ projectDir.FullPath }/bin/{ configuration }");
CopyFiles(new FilePath[] { "LICENSE", "README.md", "ReleaseNotes.md" }, $"{ projectDir.FullPath }/bin/{ configuration }");
var files = GetFiles($"{ projectDir.FullPath }/bin/{ configuration }/**/*");
files.Remove(files.Where(x => x.GetExtension() == ".nupkg").ToList());
var zipFile = File($"{ projectDir.GetDirectoryName() }-v{ semVersion }.zip");
Zip(
$"{ projectDir.FullPath }/bin/{ configuration }",
$"{ buildDir }/{ zipFile }",
files);
}
}
});

Task("MyGet")
Expand All @@ -190,7 +190,7 @@ Task("MyGet")
foreach (var nupkg in GetFiles($"{ buildDir }/*.nupkg"))
{
NuGetPush(nupkg, new NuGetPushSettings
NuGetPush(nupkg, new NuGetPushSettings
{
ApiKey = mygetKey,
Source = $"https://www.myget.org/F/{myGetFeed}/api/v2/package"
Expand All @@ -212,7 +212,7 @@ Task("NuGet")
foreach (var nupkg in GetFiles($"{ buildDir }/*.nupkg"))
{
NuGetPush(nupkg, new NuGetPushSettings
NuGetPush(nupkg, new NuGetPushSettings
{
ApiKey = nugetKey,
Source = "https://api.nuget.org/v3/index.json"
Expand All @@ -232,18 +232,18 @@ Task("GitHub")
{
throw new InvalidOperationException("Could not resolve GitHub token.");
}
var github = new GitHubClient(new ProductHeaderValue("CakeBuild"))
{
Credentials = new Credentials(githubToken)
};
var release = github.Repository.Release.Create("daveaglick", repositoryName, new NewRelease("v" + semVersion)
var release = github.Repository.Release.Create("daveaglick", repositoryName, new NewRelease("v" + semVersion)
{
Name = semVersion,
Body = string.Join(Environment.NewLine, releaseNotes.Notes),
TargetCommitish = "main"
}).Result;
foreach(var zipFile in GetFiles($"{ buildDir }/*.zip"))
{
using (var zipStream = System.IO.File.OpenRead(zipFile.FullPath))
Expand All @@ -265,21 +265,21 @@ Task("Docs")
Recipe = "Docs",
Theme = "Samson",
Preview = true
});
});
});

//////////////////////////////////////////////////////////////////////
// TASK TARGETS
//////////////////////////////////////////////////////////////////////

Task("Default")
.IsDependentOn("Test");

Task("Release")
.Description("Generates a GitHub release, pushes the NuGet package, and deploys the docs site.")
.IsDependentOn("GitHub")
.IsDependentOn("NuGet");

Task("BuildServer")
.Description("Runs a build from the build server and updates build server data.")
.IsDependentOn("Test")
Expand Down
2 changes: 1 addition & 1 deletion src/Buildalyzer.Workspaces/AnalyzerResultExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ private static IEnumerable<DocumentInfo> GetDocuments(IAnalyzerResult analyzerRe
Path.GetFileName(x),
loader: TextLoader.From(
TextAndVersion.Create(
SourceText.From(File.ReadAllText(x)), VersionStamp.Create())),
SourceText.From(File.ReadAllText(x), Encoding.Unicode), VersionStamp.Create())),
filePath: x))
?? Array.Empty<DocumentInfo>();

Expand Down

0 comments on commit 325949a

Please sign in to comment.