Skip to content
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

When adding Microsoft.AspNetCore.Mvc.Testing to test project, dotnet publish --no-build command fails with NETSDK1085 #40330

Closed
1 task done
Maxwellwr opened this issue Feb 21, 2022 · 7 comments
Labels
area-web-frameworks *DEPRECATED* This label is deprecated in favor of the area-mvc and area-minimal labels feature-mvc-testing MVC testing package
Milestone

Comments

@Maxwellwr
Copy link

Maxwellwr commented Feb 21, 2022

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

I have 2 projects.

  1. WebAPI application
  2. Unit test project.

The test project uses WebApplicationFactory, for which the Microsoft.AspNetCore.Mvc.Testing package version 6.0.2 was included. Also in the test project, the IsPublishable property is set to false.

Then a sequence of commands is executed:
dotnet restore
dotnet build -c Release --no-restore
dotnet test -c Release --no-build
dotnet publish -c Release --no-build -o app/

As a result, I get the error "NETSDK1085: The 'NoBuild' property was set to true but the 'Build' target was invoked."

Expected Behavior

WebAPI project is published without errors

Steps To Reproduce

Clone repo:
https://github.com/Maxwellwr/net6publish

Execute:
dotnet restore
dotnet build -c Release --no-restore
dotnet test -c Release --no-build
dotnet publish -c Release --no-build -o app/

Exceptions (if any)

No response

.NET Version

6.0.200

Anything else?

No response

@javiercn javiercn added area-web-frameworks *DEPRECATED* This label is deprecated in favor of the area-mvc and area-minimal labels feature-mvc-testing MVC testing package labels Feb 21, 2022
@rafikiassumani-msft rafikiassumani-msft added this to the Backlog milestone Feb 22, 2022
@ghost
Copy link

ghost commented Feb 22, 2022

We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.

@ltjax
Copy link

ltjax commented Jul 21, 2022

We have this problem as well, and I can narrow it down a little bit: It still works with Microsoft.AspNetCore.Mvc.Testing v5.0.17, but I get NETSDK1085 when I upgrade so 6.0.0

@ghost
Copy link

ghost commented Sep 20, 2022

We have this problem as well, and I can narrow it down a little bit: It still works with Microsoft.AspNetCore.Mvc.Testing v5.0.17, but I get NETSDK1085 when I upgrade so 6.0.0

I've encountered this too. The issue is still reproducible.

@chrisw000
Copy link

The workaround is to set the project referencing Microsoft.AspNetCore.Mvc.Testing is have

<IsPublishable>true</IsPublishable>

but then you can start to encounter this, so potentially more changes needed
dotnet/sdk#23839

@yodasad
Copy link

yodasad commented Nov 1, 2022

I've encountered this too. The issue is still reproducible.
I do not want to publish test projects, so IsPublishable property is set to false.

@yodasad
Copy link

yodasad commented Nov 2, 2022

Overriding the _GeneratePublishTestManifest target (for instance, in a Directory.Build.targets) by adding the '$(IsPublishable)'=='true' condition fixes the issue:

<Target Name="_GeneratePublishTestManifest" Condition="'$(IsPublishable)'=='true'" BeforeTargets="Publish" DependsOnTargets="_ResolveMvcTestProjectReferences">
   <ItemGroup>
     <_PublishManifestProjects Include="%(_ContentRootProjectReferences.FusionName)">
       <ContentRoot>~</ContentRoot>
     </_PublishManifestProjects>
     <_DepsFileToPublish Include="$([System.IO.Path]::ChangeExtension('%(_ContentRootProjectReferences.Identity)', 'deps.json'))" />
   </ItemGroup>

   <GenerateMvcTestManifestTask ManifestPath="$(PublishDir)MvcTestingAppManifest.json" Projects="@(_PublishManifestProjects)" />
   <Copy SourceFiles="%(_DepsFileToPublish.FullPath)" DestinationFolder="$(PublishDir)" Condition="Exists('%(_DepsFileToPublish.FullPath)')" />
 </Target>

It seems like the issue is fixed in 7.0: #43329.
The related issue #42966.
The commit details are here: e7f8f69

@captainsafia
Copy link
Member

Closing as this has been backported to both 7.0 and 6.0. If the issue still persists, please file a new issue and I'll let you know.

@ghost ghost locked as resolved and limited conversation to collaborators Jul 21, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-web-frameworks *DEPRECATED* This label is deprecated in favor of the area-mvc and area-minimal labels feature-mvc-testing MVC testing package
Projects
None yet
Development

No branches or pull requests

7 participants