Skip to content
This repository has been archived by the owner on Feb 8, 2022. It is now read-only.

Make it compatible with VS 2017 new .csproj format #7

Closed
patricknolan opened this issue Apr 9, 2018 · 4 comments
Closed

Make it compatible with VS 2017 new .csproj format #7

patricknolan opened this issue Apr 9, 2018 · 4 comments

Comments

@patricknolan
Copy link

patricknolan commented Apr 9, 2018

Creating new issue for the following Closed issue as I don't have permission to reopen and I don't believe issue was resolved.

Issue Url

I've uploaded sample project demonstrating error to original issue.

This is very confusing as the sample project I've uploaded is simply the default"out-of-the-box"
VS 2017 project template and ConfigurationTransform does not work.

@CometstarMH
Copy link

To reiterate/confirm the issue, I also installed v3.2 on VS2017 and when "Add Config Transforms" is run the project fails to load with the error:

error : The attribute "xmlns" in element <UsingTask> is unrecognized.

Here are the elements added to csproj files after "Add Config Transforms"

  <UsingTask TaskName="TransformXml" AssemblyFile="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\Web\Microsoft.Web.Publishing.Tasks.dll" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" />
  <Target Name="app_config_AfterCompile" AfterTargets="AfterCompile" Condition="Exists('app.$(Configuration).config')" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
    <!--Generate transformed app config in the intermediate directory-->
    <TransformXml Source="app.config" Destination="$(IntermediateOutputPath)$(TargetFileName).config" Transform="app.$(Configuration).config" />
    <!--Force build process to use the transformed configuration file from now on.-->
    <ItemGroup>
      <AppConfigWithTargetPath Remove="App.config" />
      <AppConfigWithTargetPath Include="$(IntermediateOutputPath)$(TargetFileName).config">
        <TargetPath>$(TargetFileName).config</TargetPath>
      </AppConfigWithTargetPath>
    </ItemGroup>
  </Target>
  <!--Override After Publish to support ClickOnce AfterPublish. Target replaces the untransformed config file copied to the deployment directory with the transformed one.-->
  <Target Name="app_config_AfterPublish" AfterTargets="AfterPublish" Condition="Exists('app.$(Configuration).config')" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
    <PropertyGroup>
      <DeployedConfig>$(_DeploymentApplicationDir)$(TargetName)$(TargetExt).config$(_DeploymentFileMappingExtension)</DeployedConfig>
    </PropertyGroup>
    <!--Publish copies the untransformed App.config to deployment directory so overwrite it-->
    <Copy Condition="Exists('$(DeployedConfig)')" SourceFiles="$(IntermediateOutputPath)$(TargetFileName).config" DestinationFiles="$(DeployedConfig)" />
  </Target>

Once I remove all xmlns attributes in the UsingTask and Target elements, the project can load. Configs are successfully transformed on Build, too.

Seems like specifying xmlns is not necessary here?

@s-krawczyk
Copy link

+1 have same issue.

@haha454
Copy link

haha454 commented Sep 23, 2018

@CometstarMH Removing all xmlns=... attributes would work for the new VS2017 .csproj format, but for old .csproj format, they are still necessary. I think the difficulty to determine whether to add xmlns=... is how to determine if the current .csproj format is new format or old format.

@kdjjoshi
Copy link

kdjjoshi commented Jun 4, 2020

Thanks this worked

@golavr golavr closed this as completed Feb 7, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants