How to specify output path only for single target framework in new SDK csproj project style.
My project file has this PropertyGroup:
<PropertyGroup>
<OutputType>WinExe</OutputType>
<UseWPF>true</UseWPF>
</PropertyGroup>
I tried to add something like this above this group but didn't worked:
<Choose>
<When Condition=" '$(MyMsbuildParam)' == 'False' ">
<PropertyGroup>
<TargetFrameworks>net5.0-windows10.0.18362.0;net472</TargetFrameworks>
</PropertyGroup>
</When>
<When Condition=" '$(MyMsbuildParam)' == 'True' ">
<PropertyGroup>
<TargetFrameworks>net472</TargetFrameworks>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<OutputPath >..\bin64\$(Configuration)\</OutputPath>
</PropertyGroup>
</When>
</Choose>
This is the error I'm getting:
Error MSB4044 The "ResolvePackageAssets" task was not given a value for the required parameter "TargetFramework".
C:\Program Files\dotnet\sdk\5.0.201\Sdks\Microsoft.NET.Sdk\targets\Microsoft.PackageDependencyResolution.targets 241
Related
I created a solution containing a website (not WebApp) with VS Express 2013. I use a web.Release.config file for the publish process. That worked well with VS 2013.
Now that I changed to VS 2019 Community, web.Debug.config was used for the web.config transformation though the publish was done for "Release". I suppose that is because in the configuration manager only "Debug" is possible for any configuration.
In another thread I found that I had to change website.publishproj from Debug to Release:
<Configuration Condition=" '$(Configuration)' == '' ">Release</Configuration>
Now, web.Release.config is used for the transformation:
"web.config" wurde mithilfe von "C:\Users\<project path>\Web.Release.config" in "C:\Users\<some temporary path>\obj\Release\TransformWebConfig\transformed\web.config" transformiert.
This file actually has the changes applied that are needed for Release.
However, in the destination directory web.config does not contain these changes. It seems to be the original web.config without transformation.
What must I do to make Publish copy the transformed web.config?
This is my .pubxml file:
<?xml version="1.0" encoding="utf-8"?>
<!--
Auto generated comment...
-->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<WebPublishMethod>FileSystem</WebPublishMethod>
<PublishProvider>FileSystem</PublishProvider>
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
<LastUsedPlatform>Any CPU</LastUsedPlatform>
<SiteUrlToLaunchAfterPublish />
<LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
<ExcludeApp_Data>False</ExcludeApp_Data>
<publishUrl>C:\Inetpub\vhosts\<website name>.com\httpdocs</publishUrl>
<DeleteExistingFiles>True</DeleteExistingFiles>
</PropertyGroup>
and here is website.publishproj:
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Release</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>10.0.30319</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{45ff7195-6038-4b17-91ce-611a467ac837}</ProjectGuid>
<SourceWebPhysicalPath>$(MSBuildThisFileDirectory)</SourceWebPhysicalPath>
<SourceWebVirtualPath>/(Source Path Name)</SourceWebVirtualPath>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<SourceWebProject>http://localhost:56406</SourceWebProject>
<SourceWebMetabasePath>/IISExpress/7.5/LM/W3SVC/2/ROOT</SourceWebMetabasePath>
</PropertyGroup>
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
<!-- for VS2010 we need to use 10.5 but for VS2012+ we should use VisualStudioVersion -->
<WebPublishTargetsVersion Condition=" '$(WebPublishTargetsVersion)' =='' and '$(VisualStudioVersion)' == 10.0 ">10.5</WebPublishTargetsVersion>
<WebPublishTargetsVersion Condition=" '$(WebPublishTargetsVersion)'=='' ">$(VisualStudioVersion)</WebPublishTargetsVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(WebPublishTargetsVersion)</VSToolsPath>
<_WebPublishTargetsPath Condition=" '$(_WebPublishTargetsPath)'=='' ">$(VSToolsPath)</_WebPublishTargetsPath>
<AssemblyFileVersion Condition="'$(AssemblyFileVersion)' == ''">1.0.0.0</AssemblyFileVersion>
<AssemblyVersion Condition="'$(AssemblyVersion)' == ''">1.0.0.0</AssemblyVersion>
</PropertyGroup>
<ItemGroup>
<AssemblyAttributes Include="AssemblyFileVersion">
<Value>$(AssemblyFileVersion)</Value>
</AssemblyAttributes>
<AssemblyAttributes Include="AssemblyVersion">
<Value>$(AssemblyVersion)</Value>
</AssemblyAttributes>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Accessories\Lib\Runtime\BaseLib\BaseLib.csproj">
<Project>{8A827F3E-CA83-4765-988D-937B0B608201}</Project>
<Name>BaseLib</Name>
</ProjectReference>
<ProjectReference Include="..\Accessories\Lib\Runtime\Config\Config.csproj">
<Project>{1B78D777-B4F8-4CEA-9A4F-554807D1E5BF}</Project>
<Name>Config</Name>
</ProjectReference>
<ProjectReference Include="..\Accessories\Lib\Runtime\GardenLib\GardenLib.csproj">
<Project>{30B09928-B911-4803-982F-519C4CDB8860}</Project>
<Name>GardenLib</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(_WebPublishTargetsPath)\Web\Microsoft.WebSite.Publishing.targets" />
</Project>
After I got some more problems publishing my website, I switched back to VS2013 Express where my publish process works well as it did before.
Maybe it's a bug in Visual Studio?
In my projects Visual Studio gives me recommendations to use C# 8.0 features for Framework 4.6 projects, even though the default is specified on the Microsoft documentations to be 7.3. An example of one of the suggestions:
var i1 = "";
var i2 = "";
i1 = i1 ?? i2; //suggests i1 ??= i2;
If I let VS correct the suggestions the IDE shows me no errors or warnings, but the moment I build I get a compiler error.
I know I can change the langversion in the .csproj file to get it to work, but that's not the point.
Why do I get suggestions and then proceed to get no errors until compilation?
In my memory I used to get suggestions to automatically upgrade the project to the langversion for 7.X features in the past, if I wanted to use features from that version.
Example of one of the .csproj files:
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{00000000-0000-0000-0000-000000000000}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>MyProject</RootNamespace>
<AssemblyName>MyProject</AssemblyName>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
//... References & compilation files
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
Updating the Microsoft.Net.Compilers NuGet package worked for me.
I updated from 2.10.0 to 3.11.0.
We have a F#-project that fails to build on teamctiy and can't figure out the solution to it. It seems like when building through teamcity the arguments to fsc is not correct for us. If I run msbuild /t:Rebuild /p:Configuration=Release manually on the same source it all work just fine.
I'll provide the content of the failing fsproj-file to show what I mean (it's not a large project):
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>3e68783b-823c-4394-85cb-4a05aa3f3722</ProjectGuid>
<OutputType>Library</OutputType>
<RootNamespace>SFag.DataRepository</RootNamespace>
<AssemblyName>SFag.DataRepository</AssemblyName>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<TargetFSharpCoreVersion>4.4.0.0</TargetFSharpCoreVersion>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Name>Sfag.DataRepository</Name>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<Tailcalls>false</Tailcalls>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<WarningLevel>3</WarningLevel>
<DocumentationFile>bin\Debug\SFag.DataRepository.XML</DocumentationFile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<Tailcalls>true</Tailcalls>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<WarningLevel>3</WarningLevel>
<DocumentationFile>bin\Release\SFag.DataRepository.XML</DocumentationFile>
</PropertyGroup>
<ItemGroup>
<Reference Include="mscorlib" />
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Numerics" />
</ItemGroup>
<ItemGroup>
<Compile Include="AssemblyInfo.fs" />
<Compile Include="Tilsynsmyndighet.fs" />
<None Include="Script.fsx" />
<None Include="paket.references" />
<Compile Include="KonsesjonRepository.fs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Sfag.Contracts\Sfag.Contracts.csproj">
<Name>Sfag.Contracts</Name>
<Project>{260b3032-028d-417e-acde-1c332744b1bf}</Project>
<Private>True</Private>
</ProjectReference>
</ItemGroup>
<PropertyGroup>
<MinimumVisualStudioVersion Condition="'$(MinimumVisualStudioVersion)' == ''">11</MinimumVisualStudioVersion>
</PropertyGroup>
<Choose>
<When Condition="'$(VisualStudioVersion)' == '11.0'">
<PropertyGroup Condition="Exists('$(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.FSharp.Targets')">
<FSharpTargetsPath>$(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.FSharp.Targets</FSharpTargetsPath>
</PropertyGroup>
</When>
<Otherwise>
<PropertyGroup Condition="Exists('$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\FSharp\Microsoft.FSharp.Targets')">
<FSharpTargetsPath>$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\FSharp\Microsoft.FSharp.Targets</FSharpTargetsPath>
</PropertyGroup>
</Otherwise>
</Choose>
<Import Project="$(FSharpTargetsPath)" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
<Choose>
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v4.6.1'">
<ItemGroup>
<Reference Include="FSharp.Core">
<HintPath>..\packages\FSharp.Core\lib\net40\FSharp.Core.dll</HintPath>
<Private>True</Private>
<Paket>True</Paket>
</Reference>
</ItemGroup>
</When>
</Choose>
<Choose>
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v4.6.1'">
<ItemGroup>
<Reference Include="FSharp.Data.SqlClient">
<HintPath>..\packages\FSharp.Data.SqlClient\lib\net40\FSharp.Data.SqlClient.dll</HintPath>
<Private>True</Private>
<Paket>True</Paket>
</Reference>
<Reference Include="System.Data">
<Paket>True</Paket>
</Reference>
<Reference Include="System.Xml">
<Paket>True</Paket>
</Reference>
</ItemGroup>
</When>
</Choose>
</Project>
When running msbuild manually we get the correct arguments to fsc.exe:
C:\Program Files (x86)\Microsoft SDKs\F#\4.0\Framework\v4.0\fsc.exe -o:obj\Release\SFag.DataRepository.dll --debug:pdbonly --noframework --define:TRACE --doc:bin\Release\SFag.DataRepository.XML --optimize+ -r:E:\TeamCity\buildAgent2\work\cd80d924274f60cd\src\packages\FSharp.Core\lib\net40\FSharp.Core.dll -r:E:\TeamCity\buildAgent2\work\cd80d924274f60cd\src\packages\FSharp.Data.SqlClient\lib\net40\FSharp.Data.SqlClient.dll -r:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\mscorlib.dll" -r:E:\TeamCity\buildAgent2\work\cd80d924274f60cd\src\Sfag.Contracts\bin\Release\Sfag.Contracts.dll -r:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\System.Core.dll" -r:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\System.Data.dll" -r:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\System.dll" -r:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\System.Numerics.dll" -r:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\System.Xml.dll" --target:library --warn:3 --warnaserror:76 --fullpaths --flaterrors --subsystemversion:6.00 --highentropyva+ "C:\Users\admtoja1\AppData\Local\Temp\.NETFramework,Version=v4.6.1.AssemblyAttributes.fs" AssemblyInfo.fs Tilsynsmyndighet.fs KonsesjonRepository.fs
When teamcity runs the build we don't get the exact same output:
C:\Program Files (x86)\Microsoft SDKs\F#\4.0\Framework\v4.0\fsc.exe -o:obj\Release\SFag.DataRepository.dll --debug:pdbonly --noframework --define:TRACE --doc:bin\Release\SFag.DataRepository.XML --optimize+ -r:E:\TeamCity\buildAgent2\work\cd80d924274f60cd\src\packages\FSharp.Core\lib\net40\FSharp.Core.dll -r:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\mscorlib.dll" -r:E:\TeamCity\buildAgent2\work\cd80d924274f60cd\src\Sfag.Contracts\bin\Release\Sfag.Contracts.dll -r:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\System.Core.dll" -r:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\System.Data.dll" -r:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\System.dll" -r:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\System.Numerics.dll" -r:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\System.Xml.dll" --target:library --warn:3 --warnaserror:76 --fullpaths --flaterrors --subsystemversion:6.00 --highentropyva+ "E:\TeamCity\buildAgent2\temp\buildTmp\.NETFramework,Version=v4.6.1.AssemblyAttributes.fs" AssemblyInfo.fs Tilsynsmyndighet.fs KonsesjonRepository.fs
The error is that in the Teamcity version there is no reference to FSharp.Data.SqlClient. This is really strange since I thought teamcity would just call msbuild on my solution.
FSharp.Data.Client is coming from a NuGet package and I would have a guess that NuGet packages are not being restored correctly prior to the compilation step.
Enable NuGet on TeamCity through the Administration link
Add a NuGet install step prior to the compilation step
Hope this helps
This is probably a newbie paket mistake. Since we want to have automatic resolve of the packages when we build in Visual Studio we must add one line to our project files:
<Import Project="..\.paket\paket.targets" />
And it also important that this file is in the right place in the project file. If I had it above
<Import Project="$(FSharpTargetsPath)" />
it didn't work. So I put it right below and now everything works like a charm.
I have an asp.net mvc 3 project and a separate BusinessLayer project included in the solution. When I'm trying to deploy my site to Azure via local git repository, I'm getting the following error: '<remote_path>\BusinessLayer\BusinessLayer.csproj' is not a deployable project.. No other information is provided in logs. Site perfectly deploys on my local server. So I want to know at least some possible reasons why this error occurs. Thanks in advance.
Here's my .csproj file, if necessary:
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{31F2F6FE-10D8-4510-AC61-CBE1962D3940}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>BusinessLayer</RootNamespace>
<AssemblyName>BusinessLayer</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="MongoDB.Bson">
<HintPath>..\..\Libs\MongoDB.Bson.dll</HintPath>
</Reference>
<Reference Include="MongoDB.Driver">
<HintPath>..\..\Libs\MongoDB.Driver.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Drawing" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Battle.cs" />
<Compile Include="BattleManager.cs" />
<Compile Include="BattlePlace.cs" />
<Compile Include="Helpers\ConvertHelper.cs" />
<Compile Include="Helpers\ImageHelper.cs" />
<Compile Include="Message.cs" />
<Compile Include="Picture.cs" />
<Compile Include="Place.cs" />
<Compile Include="PlaceManager.cs" />
<Compile Include="Subject.cs" />
<Compile Include="User.cs" />
<Compile Include="Helpers\DBHelper.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
You may need to tell Azure exactly which project it should deploy, which you can do using a .deployment file at the root of your project. e.g.
[config]
project = WebProject/WebProject.csproj
Please see this page for more information about this.
Sounds like you're trying to deploy the BusinessLayer project and not the Website project. As long as your MVC site project has a reference to BusinessLayer, just deploy the website. BusinessLayer will be included as a reference.
You can't deploy BusinessLayer by itself, as it is a library and not an application.
I want to replace the ProductVersion value at <DefineConstants> node of the following xml. Remaining part of the line has to be preserved.
Example:
<DefineConstants>XXXXX;ProductVersion=20.323.23;YYYYY</DefineConstants>
to
<DefineConstants>XXXXX;ProductVersion=21.58.44;YYYYY</DefineConstants>
I tried the replaceregexp but it changes the remaining contents.
<replaceregexp file="${basedir}\Installer.wixproj"
match="ProductVersion=([0-9].*);(.*)"
replace="ProductVersion=${SpaceVersion};\1"
byline="true"
/>
Could you guide me what i am doing wrong in this.
XML:
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
<ProductVersion>3.5</ProductVersion>
<ProjectGuid>{6bc0a85b-9c15-41e6-874b-5fe07e5338e6}</ProjectGuid>
<SchemaVersion>2.0</SchemaVersion>
<OutputName>Installer</OutputName>
<OutputType>Package</OutputType>
<WixTargetsPath Condition=" '$(WixTargetsPath)' == '' AND '$(MSBuildExtensionsPath32)' != '' ">$(MSBuildExtensionsPath32)\Microsoft\WiX\v3.x\Wix.targets</WixTargetsPath>
<WixTargetsPath Condition=" '$(WixTargetsPath)' == '' ">$(MSBuildExtensionsPath)\Microsoft\WiX\v3.x\Wix.targets</WixTargetsPath>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<OutputPath>bin\$(Configuration)\</OutputPath>
<IntermediateOutputPath>obj\$(Configuration)\</IntermediateOutputPath>
<DefineConstants>Debug;</DefineConstants>
<WixVariables>
</WixVariables>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<OutputPath>bin\$(Configuration)\</OutputPath>
<IntermediateOutputPath>obj\$(Configuration)\</IntermediateOutputPath>
<DefineConstants>SourceDir=$(SolutionDir)XSSE\;ProductVersion=3.3.1.75;ProductName=XSSE;ToolchinShortcut=XSSEToolchinShortcut;ExtensionDir=XSSE;ManifestFileName=extension.vsixmanifest;PkageDefFileName=XSSE.ToolchainProvider.pkgdef;REGKEY=Software\Microsoft\XSSE;</DefineConstants>
<WixVariables>XYZ=123;</WixVariables>
</PropertyGroup>
<ItemGroup>
<Compile Include="filefragment.wxs" />
<Compile Include="Product.wxs" />
</ItemGroup>
<ItemGroup>
<WixExtension Include="WixUIExtension">
<HintPath>$(WixExtDir)\WixUIExtension.dll</HintPath>
<Name>WixUIExtension</Name>
</WixExtension>
</ItemGroup>
<Import Project="$(WixTargetsPath)" />
I think trying to capture the remainder of the line after the product version is unnecessary.
You don't need to worry about that. If your regex leaves the rest of the text alone, you can just replace the ProductVersion only.
I had success with this:
<replaceregexp file="${basedir}\Installer.wixproj"
match="ProductVersion=[0-9]+\.?[0-9]+\.?[0-9]+\.?[0-9]+\.?;"
replace="ProductVersion=${SpaceVersion};"
byline="true"
/>
You need to use \2 instead of \1.
<replaceregexp file="${basedir}\Installer.wixproj"
match="ProductVersion=([0-9].*);(.*)"
replace="ProductVersion=${SpaceVersion};\2"
byline="true"
/>
Standalone test:
<project default="test">
<property name="SpaceVersion" value="a.b.c"/>
<target name="test">
<replaceregexp file="test.xml"
match="ProductVersion=([0-9].*);(.*)"
replace="ProductVersion=${SpaceVersion};\2"
byline="true"
/>
</target>
</project>
Comparison of changed file with original:
$diff test.xml test.xml.0
2c2
< <DefineConstants>XXXXX;ProductVersion=a.b.c;YYYYY</DefineConstants>
---
> <DefineConstants>XXXXX;ProductVersion=20.323.23;YYYYY</DefineConstants>