-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Common.targets support for reference assemblies #2039
Changes from 7 commits
3957d62
5c8367f
f36d4dd
ee73827
f25de78
e524382
c7e973c
6babd9f
70f1aaa
c7679e4
535af86
f357dc1
1856345
e105500
56ab56c
fc64b35
a5cf059
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -154,6 +154,9 @@ Copyright (C) Microsoft Corporation. All rights reserved. | |
<_DocumentationFileProduced>true</_DocumentationFileProduced> | ||
<_DocumentationFileProduced Condition="'$(DocumentationFile)'==''">false</_DocumentationFileProduced> | ||
|
||
<!-- Whether or not a reference assembly is produced. --> | ||
<ProduceReferenceAssembly Condition="'$(ProduceReferenceAssembly)' == '' and '$(Deterministic)' != 'true'">false</ProduceReferenceAssembly> | ||
<ProduceReferenceAssembly Condition="'$(ProduceReferenceAssembly)' == '' and '$(Deterministic)' == 'true'">true</ProduceReferenceAssembly> | ||
</PropertyGroup> | ||
|
||
<PropertyGroup Condition=" '$(OutputPath)' == '' "> | ||
|
@@ -281,6 +284,8 @@ Copyright (C) Microsoft Corporation. All rights reserved. | |
<!-- Example, c:\MyProjects\MyProject\bin\debug\MyAssembly.dll --> | ||
<TargetPath Condition=" '$(TargetPath)' == '' ">$(TargetDir)$(TargetFileName)</TargetPath> | ||
|
||
<TargetRefPath Condition=" '$(TargetRefPath)' == '' and '$(ProduceReferenceAssembly)' == 'true' ">$([MSBuild]::NormalizePath($(TargetDir), 'ref', $(TargetFileName)))</TargetRefPath> | ||
|
||
<!-- Example, c:\MyProjects\MyProject\ --> | ||
<ProjectDir Condition=" '$(ProjectDir)' == '' ">$(MSBuildProjectDirectory)\</ProjectDir> | ||
|
||
|
@@ -350,6 +355,13 @@ Copyright (C) Microsoft Corporation. All rights reserved. | |
<FinalDocFile Include="@(DocFileItem->'$(OutDir)%(Filename)%(Extension)')"/> | ||
</ItemGroup> | ||
|
||
<ItemGroup Condition="'$(Deterministic)' == 'true'"> | ||
<!-- TODO: should this be configurable? Default path obeys conventions. --> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm thinking "no", let the user define the item themselves if they want a nonstandard path. |
||
<IntermediateRefAssembly Include="$(IntermediateOutputPath)ref\$(TargetName)$(TargetExt)" Condition="'@(IntermediateRefAssembly)' == ''" /> | ||
<CreateDirectory Include="@(IntermediateRefAssembly->'%(RootDir)%(Directory)')" /> | ||
<CreateDirectory Include="$(OutDir)ref" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup Condition="'$(_DebugSymbolsProduced)' == 'true'"> | ||
<_DebugSymbolsIntermediatePath Include="$(IntermediateOutputPath)$(TargetName).compile.pdb" Condition="'$(OutputType)' == 'winmdobj' and '@(_DebugSymbolsIntermediatePath)' == ''"/> | ||
<_DebugSymbolsIntermediatePath Include="$(IntermediateOutputPath)$(TargetName).pdb" Condition="'$(OutputType)' != 'winmdobj' and '@(_DebugSymbolsIntermediatePath)' == ''"/> | ||
|
@@ -771,7 +783,7 @@ Copyright (C) Microsoft Corporation. All rights reserved. | |
Name="Build" | ||
Condition=" '$(_InvalidConfigurationWarning)' != 'true' " | ||
DependsOnTargets="$(BuildDependsOn)" | ||
Returns="$(TargetPath)" /> | ||
Returns="@(TargetPathWithTargetPlatformMoniker)" /> | ||
|
||
<!-- | ||
============================================================ | ||
|
@@ -1797,6 +1809,7 @@ Copyright (C) Microsoft Corporation. All rights reserved. | |
<TargetPathWithTargetPlatformMoniker Include="$(TargetPath)"> | ||
<TargetPlatformMoniker>$(TargetPlatformMoniker)</TargetPlatformMoniker> | ||
<TargetPlatformIdentifier>$(TargetPlatformIdentifier)</TargetPlatformIdentifier> | ||
<ReferenceAssembly Condition="'$(ProduceReferenceAssembly)' != ''">$(TargetRefPath)</ReferenceAssembly> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should this condition be if ProduceReferenceAssembly == true? Otherwise if false we'll still be setting this. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes 😳 |
||
</TargetPathWithTargetPlatformMoniker> | ||
</ItemGroup> | ||
</Target> | ||
|
@@ -2015,8 +2028,21 @@ Copyright (C) Microsoft Corporation. All rights reserved. | |
<Output TaskParameter="FilesWritten" ItemName="FileWrites"/> | ||
<Output TaskParameter="DependsOnSystemRuntime" PropertyName="DependsOnSystemRuntime"/> | ||
</ResolveAssemblyReference> | ||
|
||
<ItemGroup> | ||
<ReferencePathWithRefAssemblies Include="@(ReferencePath->'%(ReferenceAssembly)')" /> | ||
</ItemGroup> | ||
</Target> | ||
|
||
<ItemDefinitionGroup> | ||
<!-- Reference assemblies are not produced in all cases, but it's easier to consume them | ||
if this metadatum is always populated. This item definition ensures that it points | ||
to the implementation assembly unless specified. --> | ||
<ReferencePath> | ||
<ReferenceAssembly>%(FullPath)</ReferenceAssembly> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Comment this. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That is magic. ✨ There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Alas, it was too magic: #2165 |
||
</ReferencePath> | ||
</ItemDefinitionGroup> | ||
|
||
<!-- | ||
==================================================================================================== | ||
|
||
|
@@ -4007,6 +4033,18 @@ Copyright (C) Microsoft Corporation. All rights reserved. | |
|
||
</Copy> | ||
|
||
<!-- Copy the reference assembly build product (.dll or .exe). --> | ||
<CopyRefAssembly | ||
SourcePath="@(IntermediateRefAssembly)" | ||
DestinationPath="$(TargetRefPath)" | ||
Condition="'$(CopyBuildOutputToOutputDirectory)' == 'true' and '$(SkipCopyBuildProduct)' != 'true' and Exists('@(IntermediateRefAssembly)')" | ||
> | ||
|
||
<Output TaskParameter="DestinationPath" ItemName="ReferenceAssembly"/> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add output to the outputs-of-this-project item so clean works right. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will this be in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Confirmed that after my last changes |
||
<Output TaskParameter="DestinationFiles" ItemName="FileWrites"/> | ||
|
||
</CopyRefAssembly> | ||
|
||
<Message Importance="High" Text="$(MSBuildProjectName) -> @(MainAssembly->'%(FullPath)')" Condition="'$(CopyBuildOutputToOutputDirectory)' == 'true' and '$(SkipCopyBuildProduct)'!='true'" /> | ||
|
||
<!-- Copy the additional modules. --> | ||
|
@@ -4468,6 +4506,7 @@ Copyright (C) Microsoft Corporation. All rights reserved. | |
<!--Record the main compile outputs.--> | ||
<ItemGroup> | ||
<FileWrites Include="@(IntermediateAssembly)" Condition="Exists('@(IntermediateAssembly)')"/> | ||
<FileWrites Include="@(IntermediateRefAssembly)" Condition="'@(IntermediateRefAssembly)' != '' and Exists('@(IntermediateRefAssembly)')"/> | ||
</ItemGroup> | ||
|
||
<!-- Record the .xml if one was produced. --> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -172,5 +172,6 @@ | |
<!-- Roslyn tasks are now in an assembly owned and shipped by Roslyn --> | ||
<UsingTask TaskName="Microsoft.CodeAnalysis.BuildTasks.Csc" AssemblyFile="$(RoslynTargetsPath)\Microsoft.Build.Tasks.CodeAnalysis.dll" Condition="'$(MSBuildAssemblyVersion)' != ''" /> | ||
<UsingTask TaskName="Microsoft.CodeAnalysis.BuildTasks.Vbc" AssemblyFile="$(RoslynTargetsPath)\Microsoft.Build.Tasks.CodeAnalysis.dll" Condition="'$(MSBuildAssemblyVersion)' != ''" /> | ||
<UsingTask TaskName="Microsoft.CodeAnalysis.BuildTasks.CopyRefAssembly" AssemblyFile="$(RoslynTargetsPath)\Microsoft.Build.Tasks.CodeAnalysis.dll" Condition="'$(MSBuildAssemblyVersion)' != ''" /> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What's the expected behavior if the user has a newer version of the Roslyn package installed? I believe that package does UsingTasks on Csc/Vbc so those get overridden. Should we be doing the UsingTask too there so that way an upgrade also means you get a newer version here? (cc @jcouv) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Excellent catch! I added it to the Roslyn package props in dotnet/roslyn@ae50fe8 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks 😄 |
||
</Project> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs an explicit "no ref asm" off switch, as well as defaulting for
Deterministic
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Condition must also apply to
$(TargetRefPath)
.