Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 21 additions & 2 deletions GitVersionTask/AssemblyInfoBuilder/UpdateAssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@ public class UpdateAssemblyInfo : Task

[Required]
public string ProjectFile { get; set; }

[Required]
public string ProjectDir { get; set; }

[Required]
public string Configuration { get; set; }

[Required]
public ITaskItem[] CompileFiles { get; set; }

Expand Down Expand Up @@ -127,8 +134,20 @@ void CreateTempAssemblyInfo(CachedVersion semanticVersion, Config configuration)
};
var assemblyInfo = assemblyInfoBuilder.GetAssemblyInfoText(configuration);

var tempFileName = string.Format("AssemblyInfo_{0}_{1}.g.cs", Path.GetFileNameWithoutExtension(ProjectFile), Path.GetRandomFileName());
AssemblyInfoTempFilePath = Path.Combine(TempFileTracker.TempPath, tempFileName);
string tempFileName, tempDir;
if (string.IsNullOrEmpty(ProjectDir) || string.IsNullOrWhiteSpace(ProjectDir))
{
tempDir = TempFileTracker.TempPath;
tempFileName = string.Format("AssemblyInfo_{0}_{1}.g.cs", Path.GetFileNameWithoutExtension(ProjectFile), Path.GetRandomFileName());
}
else
{
tempDir = Path.Combine(ProjectDir, "obj", Configuration);
Directory.CreateDirectory(tempDir);
tempFileName = string.Format("GitVersionTaskAssemblyInfo.g.cs");
}

AssemblyInfoTempFilePath = Path.Combine(tempDir, tempFileName);
File.WriteAllText(AssemblyInfoTempFilePath, assemblyInfo);
}
}
Expand Down
2 changes: 2 additions & 0 deletions GitVersionTask/NugetAssets/GitVersionTask.targets
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
<UpdateAssemblyInfo
SolutionDirectory="$(SolutionDir)"
ProjectFile="$(ProjectPath)"
ProjectDir="$(ProjectDir)"
Configuration="$(ConfigurationName)"
AssemblyVersioningScheme="$(GitVersionAssemblyVersioningScheme)"
CompileFiles ="@(Compile)">
<Output
Expand Down