Closed richardszalay closed 5 years ago
TODO: Update the README with this information
We have a workaround in place that's been working for a few months now without expanding: move project references from the csproj into a Directory.build.props
and specify them with properties (though the latter might be optional):
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$([MSBuild]::GetPathOfFileAbove('Directory.Build.props', '$(MSBuildThisFileDirectory)../'))" />
<PropertyGroup>
<PublishProfile>Local</PublishProfile>
</PropertyGroup>
<PropertyGroup>
<DynamicProjectReferenceIncludes>$(DynamicProjectReferenceIncludes);..\..\Foundation\*\code\*.csproj</DynamicProjectReferenceIncludes>
<DynamicProjectReferenceIncludes>$(DynamicProjectReferenceIncludes);..\..\Feature\*\code\*.csproj</DynamicProjectReferenceIncludes>
<DynamicProjectReferenceIncludes>$(DynamicProjectReferenceIncludes);..\..\Project\*\code\*.csproj</DynamicProjectReferenceIncludes>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="$(DynamicProjectReferenceIncludes)" Exclude="$(DynamicProjectReferenceExcludes)" />
<!-- Properties prevent VS from expanding the matches when new projects are added -->
</ItemGroup>
</Project>
Some additional notes:
DisableFastUpToDateCheck
(auto-publish) needs to be in the csproj, it can't be in the Directory.Build.props / wpp.targetsThanks to @jeneaux for finding a repeatable method of reproducing this problem: renaming a project.
Because of that, I can now confirm that the only thing required to prevent the expansion is having the project references in a separate file.
Even though it can be any file I'm going to add support for optionally importing a file named Helix.props
and use it as the official recommendation in the README.
Actually this will require some more thought: when using PackageReference
the import to the library's targets is added at build time. It's possible that VS will also process it at design time, but it will need some testing.
Failing that we can stick with the Directory.Build.props
recommendation.
Visual Studio seems to occasionally expand globbed project references. Apparently this can be prevented by defining the globs in a Property and then referencing that property in the Item. Just need to confirm this and update the README.