Skip to content

Conversation

@joj
Copy link
Member

@joj joj commented Aug 28, 2023

Esprojs may be referenced by ASP.Net projects (or others). When this happens, the .net project will have to not reference output assembly on the esproj, because there is no output assembly. This targets file provides that behavior.

Esprojs may be referenced by ASP.Net projects (or others). When this
happens, the .net project will have to not reference output assembly
on the esproj, because there is no output assembly. This targets file
provides that behavior.
@ghost ghost added Area-Infrastructure untriaged Request triage from a team member labels Aug 28, 2023
@baronfel
Copy link
Member

baronfel commented Aug 28, 2023

cc @rainersigwald @dsplaisted for review/insight here - @joj is from the esproj team trying to make consuming .esproj projects nicer for other SDK-style projects in general. Right now, consumers of .esproj ProjectReferences have to markup every one of their references.

Ideally this is something that could be done in by the esproj targets themselves, but these references are on the consuming side. We couldn't find another viable extension spot given the current ways we have to extend MSBuild, so this was the best thing that could be found.

If we take this we would also need to coordinate with VS to get the same file in their mirrored MSBuild extensions layout path.

@dsplaisted
Copy link
Member

Seems fine to me. Does this need to work in non-SDK style consuming projects? If not, it would probably be easier to put it somewhere in the .NET SDK targets, and you wouldn't have to worry about mirroring it for .NET CLI and full MSBuild.

@KalleOlaviNiemitalo
Copy link
Contributor

KalleOlaviNiemitalo commented Aug 29, 2023

I thought this could be done as an ItemDefinitionGroup, but I got error MSB4190 when I tried.

<Project>
  <ItemDefinitionGroup>
    <ProjectReference>
      <ReferenceOutputAssembly Condition="'%(ProjectReference.Extension)' == '.esproj'">false</ReferenceOutputAssembly>
    </ProjectReference>
  </ItemDefinitionGroup>

  <ItemGroup>
    <ProjectReference Include="huhhuh.esproj" />
  </ItemGroup>

  <Target Name="Build">
    <Message Text="ProjectReference %(ProjectReference.Identity) %(ProjectReference.ReferenceOutputAssembly)" />
  </Target>
</Project>

error MSB4190: The reference to the built-in metadata "Extension" at position 1 is not allowed in this condition "'%(ProjectReference.Extension)' == '.esproj'".

@joj
Copy link
Member Author

joj commented Aug 29, 2023

I tried the ItemDefinitionGroup and couldn't make it work, but I do believe the target still makes a lot of sense. @dsplaisted I'm all for a better location for this targets file. Where would a good location in .Net SDK Targets be? I wasn't sure, so just looked for other well known common after targets :)

@joj
Copy link
Member Author

joj commented Aug 29, 2023

Oh, wait, just re-read that: this does in fact need to work for non-SDK Style projects. ASP.Net (.Net Framework) has the same scenario as the .Net Core version has.

@rainersigwald
Copy link
Member

this does in fact need to work for non-SDK Style projects

Then the best home for this is probably in https://github.com/dotnet/msbuild/blob/main/src/Tasks/Microsoft.Common.CurrentVersion.targets.

@joj
Copy link
Member Author

joj commented Aug 29, 2023

You mean modifying the actual common file? I can do that... I thought the bar was very high on that one :)

@rainersigwald
Copy link
Member

It is pretty high, but it's the only way to get common functionality between .NET SDK and VS. Were you thinking of shipping this ImportAfter to VS in a VSIX as well as here?

@joj
Copy link
Member Author

joj commented Aug 29, 2023

Yes on shipping vsix, but I would rather do common tbh. The problem with vsix is that it will only happen if we actually have the workload. In some corner cases that may not be true. I'll amend this PR today.

joj added a commit to dotnet/msbuild that referenced this pull request Sep 1, 2023
Esprojs may be referenced by ASP.Net projects (or others). When this happens,
the .net project will have to not reference output assembly on the esproj,
because there is no output assembly. This targets provides that behavior.
There was an argument for putting this in this file instead of in the sdk.
The discussion can be found here: dotnet/sdk#34983
@joj
Copy link
Member Author

joj commented Sep 1, 2023

Moved to msbuild to live in currentversion targets

@joj joj closed this Sep 1, 2023
rainersigwald pushed a commit to dotnet/msbuild that referenced this pull request Sep 21, 2023
Setting ReferenceOutputAssembly to falso on references to esproj
Esprojs may be referenced by ASP.Net projects (or others). When this happens,
the .net project will have to not reference output assembly on the esproj,
because there is no output assembly. This targets provides that behavior.
There was an argument for putting this in this file instead of in the sdk.
The discussion can be found here: dotnet/sdk#34983
@akoeplinger akoeplinger deleted the dev/joj/esprojnoasm branch February 14, 2024 14:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area-NetSDK untriaged Request triage from a team member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants