Skip to content

Commit

Permalink
Set DebugType and DebugSymbols unconditionally (#360)
Browse files Browse the repository at this point in the history
It's fairly common for repositories to set a default DebugType and/or DebugSymbols setting in their Directory.Build.props file. As an example, Arcade does that which impacts every repository in the .NET stack. The NoTargets SDK should overwrite these default settings (including the Microsoft.NET.Sdk setting) as the project clearly doesn't produce a symbol. Setting in the props file to allow a project to overwrite the setting if it explicitly wants to do so.
  • Loading branch information
ViktorHofer authored May 19, 2022
1 parent 0167add commit 9af7ea2
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 39 deletions.
2 changes: 1 addition & 1 deletion azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ variables:
BuildConfiguration: 'Debug'
BuildPlatform: 'Any CPU'
DotNet3Version: '3.x'
DotNet6Version: '6.x'
DotNet6Version: '6.0.203'
MSBuildArgs: '"/p:Platform=$(BuildPlatform)" "/p:Configuration=$(BuildConfiguration)" "/BinaryLogger:$(Build.SourcesDirectory)\$(ArtifactsDirectoryName)\msbuild.binlog"'
SignType: 'Test'

Expand Down
42 changes: 28 additions & 14 deletions src/NoTargets.UnitTests/NoTargetsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -155,23 +155,37 @@ public void ProjectsCanDependOnNoTargetsProjects()
}

[Theory]
[InlineData("DisableImplicitFrameworkReferences", "true")]
[InlineData("EnableDefaultCompileItems", "false")]
[InlineData("EnableDefaultEmbeddedResourceItems", "false")]
[InlineData("GenerateAssemblyInfo", "false")]
[InlineData("GenerateMSBuildEditorConfigFile", "false")]
[InlineData("IncludeBuildOutput", "false")]
[InlineData("ProduceReferenceAssembly", "false")]
[InlineData("SkipCopyBuildProduct", "true")]
[InlineData("AutomaticallyUseReferenceAssemblyPackages", "false")]
[InlineData("NoCompilerStandardLib", "false")]
[InlineData("DebugType", "None")]
[InlineData("DebugSymbols", "false")]
[InlineData("DisableFastUpToDateCheck", "true")]
public void PropertiesHaveExpectedValues(string propertyName, string expectedValue)
[InlineData("AutomaticallyUseReferenceAssemblyPackages", "true", "true")]
[InlineData("AutomaticallyUseReferenceAssemblyPackages", null, "false")]
[InlineData("DebugSymbols", "true", "false")]
[InlineData("DebugSymbols", null, "false")]
[InlineData("DebugType", "Full", "None")]
[InlineData("DebugType", null, "None")]
[InlineData("DisableFastUpToDateCheck", "false", "false")]
[InlineData("DisableFastUpToDateCheck", null, "true")]
[InlineData("DisableImplicitFrameworkReferences", "false", "false")]
[InlineData("DisableImplicitFrameworkReferences", null, "true")]
[InlineData("EnableDefaultCompileItems", "true", "true")]
[InlineData("EnableDefaultCompileItems", null, "false")]
[InlineData("EnableDefaultEmbeddedResourceItems", "true", "true")]
[InlineData("EnableDefaultEmbeddedResourceItems", null, "false")]
[InlineData("GenerateAssemblyInfo", "true", "true")]
[InlineData("GenerateAssemblyInfo", null, "false")]
[InlineData("GenerateMSBuildEditorConfigFile", "true", "true")]
[InlineData("GenerateMSBuildEditorConfigFile", null, "false")]
[InlineData("IncludeBuildOutput", "true", "true")]
[InlineData("IncludeBuildOutput", null, "false")]
[InlineData("NoCompilerStandardLib", "true", "true")]
[InlineData("NoCompilerStandardLib", null, "false")]
[InlineData("ProduceReferenceAssembly", "true", "false")]
[InlineData("ProduceReferenceAssembly", null, "false")]
[InlineData("SkipCopyBuildProduct", "false", "false")]
[InlineData("SkipCopyBuildProduct", null, "true")]
public void PropertiesHaveExpectedValues(string propertyName, string value, string expectedValue)
{
ProjectCreator.Templates.NoTargetsProject(
path: GetTempFileWithExtension(".csproj"))
.Property(propertyName, value)
.Save()
.TryGetPropertyValue(propertyName, out string actualValue);

Expand Down
4 changes: 0 additions & 4 deletions src/NoTargets/Sdk/Sdk.props
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,6 @@
<AutomaticallyUseReferenceAssemblyPackages Condition="'$(AutomaticallyUseReferenceAssemblyPackages)' == ''">false</AutomaticallyUseReferenceAssemblyPackages>
<NoCompilerStandardLib Condition="'$(NoCompilerStandardLib)' == ''">false</NoCompilerStandardLib>

<!-- Indicate no symbols will be generated -->
<DebugType Condition="'$(DebugType)' == ''">None</DebugType>
<DebugSymbols Condition="'$(DebugSymbols)' == ''">false</DebugSymbols>

<!-- Disable Visual Studio's Fast Up-to-date Check and rely on MSBuild to determine -->
<DisableFastUpToDateCheck Condition="'$(DisableFastUpToDateCheck)' == ''">true</DisableFastUpToDateCheck>
</PropertyGroup>
Expand Down
35 changes: 16 additions & 19 deletions src/NoTargets/Sdk/Sdk.targets
Original file line number Diff line number Diff line change
Expand Up @@ -29,25 +29,7 @@
<Import Project="Sdk.targets" Sdk="Microsoft.NET.Sdk" Condition=" '$(CommonTargetsPath)' == '' " />

<PropertyGroup>
<!-- Don't emit a reference assembly -->
<ProduceReferenceAssembly>false</ProduceReferenceAssembly>
</PropertyGroup>

<ItemGroup>
<IntermediateAssembly Remove="@(IntermediateAssembly)" />
<IntermediateRefAssembly Remove="@(IntermediateRefAssembly)" />
</ItemGroup>

<!-- Clear output group items which are read by the IDE and NuGet. -->
<ItemGroup>
<BuiltProjectOutputGroupKeyOutput Remove="@(BuiltProjectOutputGroupKeyOutput)" />
<DebugSymbolsProjectOutputGroupOutput Remove="@(DebugSymbolsProjectOutputGroupOutput)" />
</ItemGroup>

<PropertyGroup>
<!--
This property must be overridden to remove a few targets that compile assemblies
-->
<!-- This property must be overridden to remove a few targets that compile assemblies -->
<CoreBuildDependsOn>
BuildOnlySettings;
PrepareForBuild;
Expand All @@ -59,8 +41,23 @@
IncrementalClean;
PostBuildEvent
</CoreBuildDependsOn>

<!-- Disable symbol generation -->
<DebugType>None</DebugType>
<DebugSymbols>false</DebugSymbols>

<!-- Don't emit a reference assembly -->
<ProduceReferenceAssembly>false</ProduceReferenceAssembly>
</PropertyGroup>

<!-- Clear output group items which are read by the IDE and NuGet. -->
<ItemGroup>
<BuiltProjectOutputGroupKeyOutput Remove="@(BuiltProjectOutputGroupKeyOutput)" />
<DebugSymbolsProjectOutputGroupOutput Remove="@(DebugSymbolsProjectOutputGroupOutput)" />
<IntermediateAssembly Remove="@(IntermediateAssembly)" />
<IntermediateRefAssembly Remove="@(IntermediateRefAssembly)" />
</ItemGroup>

<!--
The CopyFilesToOutputDirectory target is hard coded to depend on ComputeIntermediateSatelliteAssemblies. NoTargets projects do no generate resource assemblies
so the target is replaced with a no-op
Expand Down
2 changes: 1 addition & 1 deletion src/NoTargets/version.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"inherit": true,
"version": "3.4"
"version": "3.5"
}

0 comments on commit 9af7ea2

Please sign in to comment.