Skip to content
This repository has been archived by the owner on Nov 20, 2018. It is now read-only.

dotnet-user-secrets breaks when project uses implicit imports #242

Closed
natemcmaster opened this issue Dec 7, 2016 · 3 comments
Closed

dotnet-user-secrets breaks when project uses implicit imports #242

natemcmaster opened this issue Dec 7, 2016 · 3 comments

Comments

@natemcmaster
Copy link
Contributor

natemcmaster commented Dec 7, 2016

Repro:

<Project ToolsVersion="15.0" Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>netcoreapp1.0</TargetFramework>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="Microsoft.NETCore.App" Version="1.0.1" />
    <DotNetCliToolReference Include="Microsoft.Extensions.SecretManager.Tools" Version="1.0.0-msbuild2-final" />
  </ItemGroup>
</Project>

dotnet-cli 1.0.0-preview4-004215
Run any dotnet user-secrets command

Error:

debug: Project file path C:\Users\namc\Documents\Visual Studio 2017\Projects\WebApplication1\src\WebApplication2\WebApplication2.csproj.
debug: C:\Program Files\dotnet\sdk\1.0.0-preview4-004215\Sdks\Microsoft.NET.Sdk\Sdk\Sdk.targets(35,3): error MSB4102: The value "" of the "Project" attribute in element <Import> is invalid. Parameter "path" cannot have zero length. [C:\Users\namc\.nuget\packages\microsoft.extensions.secretmanager.tools\1.0.0-msbuild2-final\tools\FindUserSecretsProperty.targets]
fail: Could not load the MSBuild project 'C:\Users\namc\Documents\Visual Studio 2017\Projects\WebApplication1\src\WebApplication2\WebApplication2.csproj'.

cref dotnet/msbuild#1392

@natemcmaster
Copy link
Contributor Author

Caused by dotnet/msbuild#1451

natemcmaster pushed a commit that referenced this issue Dec 7, 2016
Implicit imports prevents using <Import> on a project file that has the Sdk attribute. This change instead generates a file in the MSBuildProjectExtensionsPath to inject targets require to find the UserSecretsId property in a project.

Resolves #242
@rainersigwald
Copy link

That particular error is actually caused by https://github.com/dotnet/sdk/blob/c82725bc657ad369ecd4e59bf860acf6205027b6/src/Tasks/Microsoft.NET.Build.Tasks/sdk/Sdk.targets#L28-L35. You should be able to work around it by changing the generate-temp-project-with-an-import-of-the-real-project code to ensure that the generated temp file has the same extension as the user project in

natemcmaster pushed a commit that referenced this issue Dec 8, 2016
Implicit imports prevents using <Import> on a project file that has the Sdk attribute. This change instead generates a file in the MSBuildProjectExtensionsPath to inject targets require to find the UserSecretsId property in a project.

Resolves #242
@natemcmaster
Copy link
Contributor Author

natemcmaster commented Dec 8, 2016

Fixed in #243. Users should upgrade Microsoft.Extensions.SecretManager.Tools to 1.0.0-msbuild2-update1.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants