I have a PostBuild event which invokes a batch file and I need to pass in a particular parameter into the batch file. This parameter is populated through another task which is invoked through a Target configured to run before the PostBuildEvent.
I can see that it gets successfully displayed when displayed using the element as part of the section.
But $(TargetFrameworkToolsFolderPath) under the PostBuildEvent has an "" value. Is there a way to access this custom property in the post build event?
Example:
<UsingTask TaskName="GetTargetFrameworkToolsFolderName" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.Core.dll">
<ParameterGroup>
<SDKFolderPath ParameterType="System.String" Required="true" />
<TargetFrameworkVersionStr ParameterType="System.String" Required="true" />
<TargetFrameworkToolsFolder ParameterType="System.String" Output="true" />
</ParameterGroup>
<Task>
<Code Type="Fragment" Language="cs">
TargetFrameworkToolsFolder = SDKFolderPath + "\\" + "bin\\NETFX " + TargetFrameworkVersionStr.Substring(1) + " Tools\\";
</Code>
</Task>
</UsingTask>
<Target Name="FindTargetFrameworkToolsFolderPath" BeforeTargets="PostBuildEvent">
<GetFrameworkSdkPath>
<Output TaskParameter="Path" PropertyName="SdkPath" />
</GetFrameworkSdkPath>
<GetTargetFrameworkToolsFolderName SDKFolderPath="$(SdkPath)" TargetFrameworkVersionStr="$(TargetFrameworkVersion)">
<Output PropertyName="TargetFrameworkToolsFolderPath" TaskParameter="TargetFrameworkToolsFolder"/>
</GetTargetFrameworkToolsFolderName>
<Message Text="$(TargetFrameworkToolsFolderPath)" Importance="normal" /> --> Displayed correctly here
</Target>
<PropertyGroup>
<PostBuildEvent>
call $(ProjectDir)AfterBuildCommands.bat $(TargetFrameworkToolsFolderPath) --> The TargetFrameworkToolsFolderPath property value here seems to be empty.
</PostBuildEvent>
</PropertyGroup>
But $(TargetFrameworkToolsFolderPath) under the PostBuildEvent has an
"" value. Is there a way to access this custom property in the post
build event?
In fact, <PostBuildEvent> is a property and MSBuild reads all the properties first and then executes all targets.
If you put these below outside the target which defines the property TargetFrameworkToolsFolderPath, these below will always execute first, as expected, the values of TargetFrameworkToolsFolderPath will be empty.
To avoid it, you should put the PostBuildEvent and TargetFrameworkToolsFolderPath properties in the same target and make sure the target is executed early enough, such as, run after PrepareForBuild target.
<PropertyGroup>
<PostBuildEvent>
call $(ProjectDir)AfterBuildCommands.bat $(TargetFrameworkToolsFolderPath) --> The TargetFrameworkToolsFolderPath property value here seems to be empty.
</PostBuildEvent>
</PropertyGroup>
Solution
Try this below:
<UsingTask TaskName="GetTargetFrameworkToolsFolderName" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.Core.dll">
<ParameterGroup>
<SDKFolderPath ParameterType="System.String" Required="true" />
<TargetFrameworkVersionStr ParameterType="System.String" Required="true" />
<TargetFrameworkToolsFolder ParameterType="System.String" Output="true" />
</ParameterGroup>
<Task>
<Code Type="Fragment" Language="cs">
TargetFrameworkToolsFolder = SDKFolderPath + "\\" + "bin\\NETFX " + TargetFrameworkVersionStr.Substring(1) + " Tools\\";
</Code>
</Task>
</UsingTask>
<Target Name="MyFindTargetFrameworkToolsFolderPath" AfterTargets="PrepareForBuild">
<GetFrameworkSdkPath>
<Output TaskParameter="Path" PropertyName="SdkPath" />
</GetFrameworkSdkPath>
<GetTargetFrameworkToolsFolderName SDKFolderPath="$(SdkPath)" TargetFrameworkVersionStr="$(TargetFrameworkVersion)">
<Output PropertyName="TargetFrameworkToolsFolderPath" TaskParameter="TargetFrameworkToolsFolder" />
</GetTargetFrameworkToolsFolderName>
<PropertyGroup>
<PostBuildEvent> call $(ProjectDir)AfterBuildCommands.bat $(TargetFrameworkToolsFolderPath) --> The TargetFrameworkToolsFolderPath property value here seems to be empty.</PostBuildEvent>
</PropertyGroup>
<Message Text="$(TargetFrameworkToolsFolderPath)" Importance="normal" />
</Target>
Hope it could help you.
I have a requirement at work to have two separate webpack instances which will essentially handle two different "sites" on the same domain.
Here is my project structure:
App1/
App2/
webpack.config.js
App2-webpack.config.js
Basically, I want to be able to be able to have all routes that start with /App2 use the App2 webpack config file and all other routes be handled by the other webpack file. Both App1 and App2 folders are completely separate instances of react, react router and redux.
I'm using the "ASP.NET Core Web Application" template from visual studio (https://github.com/aspnet/JavaScriptServices) if that helps. I've modified the csproj file and added some more commands for the second webpack bundle:
<Target Name="RunWebpackDebug" AfterTargets="AfterBuild" Condition="'$(Configuration)' == 'Debug'">
<Exec Command="npm install" />
<Exec Command="webpack --config App2-webpack.config.vendor.js" />
<Exec Command="node node_modules/webpack/bin/webpack.js --config webpack.config.js" />
<Exec Command="node node_modules/webpack/bin/webpack.js --config App2-webpack.config.js" />
</Target>
However I'm getting the error:
The command "webpack --config App2-webpack.config.vendor.js" exited with code 9009.
If I run the offending command in command prompt, I get a more specific error message:
Cannot find module './App2/wwwroot/dist/vendor-manifest.json' at ...
My guess is the fact that I'm trying to use the wwwroot folder inside my App2 folder (to keep the two apps separate) doesn't work (usually the wwwroot folder is in the root folder).
Also, is the intended functionality even possible? Thanks
EDIT: here is my webpack file for the second app:
const path = require('path');
const webpack = require('webpack');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const CheckerPlugin = require('awesome-typescript-loader').CheckerPlugin;
const merge = require('webpack-merge');
const CopyWebPackPlugin = require('copy-webpack-plugin');
const CompressionPlugin = require("compression-webpack-plugin");
module.exports = (env) => {
const isDevBuild = !(env && env.prod);
// Configuration in common to both client-side and server-side bundles
const sharedConfig = () => ({
stats: { modules: false },
resolve: { extensions: ['.js', '.jsx', '.ts', '.tsx'] },
output: {
filename: '[name].js',
publicPath: '/dist/' // Webpack dev middleware, if enabled, handles requests for this URL prefix
},
module: {
rules: [
{
test: /\.ts$/,
enforce: 'pre',
loader: 'tslint-loader',
options: {
tsConfigFile: 'tsconfig.json'
}
},
{ test: /\.tsx?$/, include: /ClientApp/, use: 'awesome-typescript-loader?silent=true' }
]
},
plugins: [new CheckerPlugin(),
new CopyWebPackPlugin([{ from: 'static' }])
]
});
// Configuration for client-side bundle suitable for running in browsers
const clientBundleOutputDir = './wwwroot/dist';
const clientBundleConfig = merge(sharedConfig(), {
entry: { 'main-client': './ClientApp/boot-client.tsx' },
module: {
rules: [
{ test: /\.less$/, exclude: /node_modules/, use: ExtractTextPlugin.extract(['css-loader', 'less-loader']) },
{ test: /\.css$/, exclude: /node_modules/, use: ExtractTextPlugin.extract({ use: 'css-loader' }) },
{ test: /\.(png|jpg|jpeg|gif|svg|woff|woff2|eot|ttf)$/, exclude: /node_modules/, use: 'url-loader?limit=25000' },
]
},
output: {
path: path.join(__dirname, clientBundleOutputDir)
},
plugins: [
new ExtractTextPlugin('site.css'),
new webpack.DllReferencePlugin({
context: __dirname,
manifest: require('./wwwroot/dist/vendor-manifest.json')
})
].concat(isDevBuild ? [
// Plugins that apply in development builds only
new webpack.SourceMapDevToolPlugin({
filename: '[file].map', // Remove this line if you prefer inline source maps
moduleFilenameTemplate: path.relative(clientBundleOutputDir, '[resourcePath]') // Point sourcemap entries to the original file locations on disk
})
] : [])
});
// Configuration for server-side (prerendering) bundle suitable for running in Node
const serverBundleConfig = merge(sharedConfig(), {
resolve: { mainFields: ['main'] },
entry: { 'main-server': './ClientApp/boot-server.tsx' },
plugins: [
new webpack.DllReferencePlugin({
context: __dirname,
manifest: require('./ClientApp/dist/vendor-manifest.json'),
sourceType: 'commonjs2',
name: './vendor'
})
],
output: {
libraryTarget: 'commonjs',
path: path.join(__dirname, './ClientApp/dist')
},
target: 'node',
devtool: 'inline-source-map'
});
const externalConfig = merge(sharedConfig(), {
entry: { 'external-shell-actions': './ClientApp/actions/externalShellActions' },
output: {
path: path.resolve(__dirname, './dist'),
filename: 'external-shell-actions.js',
library: 'externalShellActions',
libraryTarget: 'umd'
}
});
return [clientBundleConfig, serverBundleConfig, externalConfig];
};
And here is my csproj file:
<Project ToolsVersion="15.0" Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup Label="Globals">
<SccProjectName>SAK</SccProjectName>
<SccProvider>SAK</SccProvider>
<SccAuxPath>SAK</SccAuxPath>
<SccLocalPath>SAK</SccLocalPath>
<TypeScriptToolsVersion>2.3</TypeScriptToolsVersion>
</PropertyGroup>
<PropertyGroup>
<TargetFramework>net462</TargetFramework>
<RuntimeIdentifier>win7-x86</RuntimeIdentifier>
<TypeScriptCompileBlocked>true</TypeScriptCompileBlocked>
<AssetTargetFallback>$(AssetTargetFallback);portable-net45+win8+wp8+wpa81;</AssetTargetFallback>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<DebugType>portable</DebugType>
<DebugSymbols>True</DebugSymbols>
<PlatformTarget>x86</PlatformTarget>
<OutputPath>bin\Debug\net462\</OutputPath>
<DefineConstants>TRACE;DEBUG;NET462</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x86'">
<DebugType>portable</DebugType>
<DebugSymbols>True</DebugSymbols>
<PlatformTarget>x86</PlatformTarget>
<OutputPath>bin\Debug\</OutputPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<OutputPath>bin\Release\</OutputPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='ProductionRelease|AnyCPU'">
<OutputPath>bin\Release\</OutputPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x86'">
<OutputPath>bin\Release\</OutputPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='ProductionRelease|x86'">
<OutputPath>bin\Release\</OutputPath>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="AspNetCore.Antiforgery.Aes" Version="1.0.4" />
<PackageReference Include="AutoMapper" Version="6.1.1" />
<PackageReference Include="log4net" Version="2.0.8" />
<PackageReference Include="Microsoft.AspNetCore" Version="2.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.Cookies" Version="2.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="2.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="2.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.ViewCompilation" Version="2.0.0" PrivateAssets="All" />
<PackageReference Include="Microsoft.AspNetCore.Session" Version="2.0.0" />
<PackageReference Include="Microsoft.AspNetCore.SpaServices" Version="2.0.0" />
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="2.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="2.0.0" PrivateAssets="All" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="2.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="2.0.0" PrivateAssets="All" />
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.Caching.SqlServer" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="2.0.0" />
<PackageReference Include="Microsoft.VisualStudio.Web.BrowserLink" Version="2.0.0" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.0.0" PrivateAssets="All" />
<PackageReference Include="NETStandard.Library" Version="2.0.0" />
</ItemGroup>
<ItemGroup>
<!-- Files not to show in IDE -->
<None Remove="App.POS.View.React.csproj.vspscc" />
<None Remove="App2\Routes.tsx" />
<None Remove="yarn.lock" />
<Compile Remove="ClientApp\components\assets\**" />
<Compile Remove="ClientApp\dist\**" />
<Compile Remove="node_modules\postcss-zindex\postcss-unique-selectors\**" />
<Compile Remove="wwwroot\dist\**" />
<!-- Files not to publish (note that the 'dist' subfolders are re-added below) -->
<Content Remove="ClientApp\**" />
<Content Remove="node_modules\postcss-zindex\postcss-unique-selectors\**" />
<Content Remove="wwwroot\dist\**" />
<EmbeddedResource Remove="ClientApp\components\assets\**" />
<EmbeddedResource Remove="ClientApp\dist\**" />
<EmbeddedResource Remove="node_modules\postcss-zindex\postcss-unique-selectors\**" />
<EmbeddedResource Remove="wwwroot\dist\**" />
<None Remove="ClientApp\components\assets\**" />
<None Remove="ClientApp\dist\**" />
<None Remove="node_modules\postcss-zindex\postcss-unique-selectors\**" />
<None Remove="wwwroot\dist\**" />
</ItemGroup>
<ItemGroup>
<None Include="Properties\PublishProfiles\FolderProfile.pubxml.user" />
</ItemGroup>
<ItemGroup>
<Reference Include="System.Configuration" />
</ItemGroup>
<ItemGroup>
<None Update="log4net.config">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<Folder Include="static\images\" />
</ItemGroup>
<ItemGroup>
<TypeScriptCompile Include="ClientApp\actions\01.ts" />
<TypeScriptCompile Include="ClientApp\actions\0.ts" />
<TypeScriptCompile Include="ClientApp\components\1.tsx" />
<TypeScriptCompile Include="ClientApp\components\2.tsx" />
<TypeScriptCompile Include="ClientApp\components\3.tsx" />
<TypeScriptCompile Include="ClientApp\components\4.tsx" />
<TypeScriptCompile Include="ClientApp\components\5.tsx" />
<TypeScriptCompile Include="ClientApp\components\common\6.tsx" />
<TypeScriptCompile Include="ClientApp\components\common\7.tsx" />
<TypeScriptCompile Include="ClientApp\components\8.tsx" />
<TypeScriptCompile Include="ClientApp\components\9.tsx" />
<TypeScriptCompile Include="ClientApp\reducers\10.ts" />
<TypeScriptCompile Include="App2\actions\2.ts" />
<TypeScriptCompile Include="App2\components\Layout.tsx" />
<TypeScriptCompile Include="App2\components\1\1.tsx" />
<TypeScriptCompile Include="App2\components\1\2.tsx" />
<TypeScriptCompile Include="App2\containers\1.tsx" />
<TypeScriptCompile Include="App2\routes.tsx" />
</ItemGroup>
<Target Name="RunWebpackDebug" AfterTargets="AfterBuild" Condition="'$(Configuration)' == 'Debug'">
<Exec Command="npm install" />
<Exec Command="node_modules\.bin\webpack --config App2-webpack.config.vendor.js" />
<Exec Command="node node_modules/webpack/bin/webpack.js --config App2-webpack.config.js" />
<Exec Command="node_modules\.bin\webpack --config webpack.config.js" />
<Exec Command="node node_modules/webpack/bin/webpack.js --config webpack.config.js" />
</Target>
<Target Name="RunWebpackRelease" AfterTargets="AfterBuild" Condition="'$(Configuration)' == 'Release'">
<Exec Command="npm install" />
<Exec Command="node_modules\.bin\webpack --config App2-webpack.config.vendor.js" />
<Exec Command="node node_modules/webpack/bin/webpack.js --config webpack.config.vendor.production.js --env.prod" />
<Exec Command="node node_modules/webpack/bin/webpack.js --config webpack.config.production.js --env.prod" />
<Exec Command="node node_modules/webpack/bin/webpack.js --config App2-webpack.config.vendor.production.js --env.prod" />
<Exec Command="node node_modules/webpack/bin/webpack.js --config App2-webpack.config.production.js --env.prod" />
</Target>
<Target Name="RunWebpackProductionRelease" AfterTargets="AfterBuild" Condition="'$(Configuration)' == 'ProductionRelease'">
<Exec Command="npm install" />
<Exec Command="node_modules\.bin\webpack --config App2-webpack.config.vendor.js" />
<Exec Command="node node_modules/webpack/bin/webpack.js --config webpack.config.vendor.production.js --env.prod" />
<Exec Command="node node_modules/webpack/bin/webpack.js --config webpack.config.production.js --env.prod" />
<Exec Command="node node_modules/webpack/bin/webpack.js --config App2-webpack.config.vendor.production.js --env.prod" />
<Exec Command="node node_modules/webpack/bin/webpack.js --config App2-webpack.config.production.js --env.prod" />
</Target>
<Target Name="RunWebpack" AfterTargets="ComputeFilesToPublish">
<!-- As part of publishing, ensure the JS resources are freshly built in production mode -->
<Exec Command="npm install" />
<Exec Command="node_modules\.bin\webpack --config App2-webpack.config.vendor.js" />
<Exec Command="node node_modules/webpack/bin/webpack.js --config webpack.config.vendor.production.js --env.prod" />
<Exec Command="node node_modules/webpack/bin/webpack.js --config webpack.config.production.js --env.prod" />
<Exec Command="node node_modules/webpack/bin/webpack.js --config App2-webpack.config.vendor.production.js --env.prod" />
<Exec Command="node node_modules/webpack/bin/webpack.js --config App2-webpack.config.production.js --env.prod" />
<!-- Include the newly-built files in the publish output -->
<ItemGroup>
<DistFiles Include="wwwroot\dist\**; ClientApp\dist\**; App2\dist\**" />
<ResolvedFileToPublish Include="#(DistFiles->'%(FullPath)')" Exclude="#(ResolvedFileToPublish)">
<RelativePath>%(DistFiles.Identity)</RelativePath>
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</ResolvedFileToPublish>
</ItemGroup>
</Target>
<ProjectExtensions><VisualStudio><UserProperties package_1json__JSONSchema="http://json.schemastore.org/schema-catalog" /></VisualStudio></ProjectExtensions>
</Project>
I've upgraded Visual Studio from 2010 to 2015 but i'm getting a project incompatible error as per the screenshot below:
When i open the ****.csproj_deploy.wdproj file here's the contents, company name redacted:
<?xml version="1.0" encoding="utf-8"?>
<!--
Microsoft Visual Studio 2008 Web Deployment Project
http://go.microsoft.com/fwlink/?LinkID=104956
-->
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ProjectName>*********</ProjectName>
<BuildDir>..\..\..\..\target</BuildDir>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>10.0.30319</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{4981E0AB-A55B-46AE-B55F-B607E3B4EAA5}</ProjectGuid>
<SourceWebPhysicalPath>..\..\webapp</SourceWebPhysicalPath>
<SourceWebProject>{BF29C57D-D568-4195-9DE5-E5F179E19A0C}|src\main\webapp\*********.csproj</SourceWebProject>
<SourceWebVirtualPath>/*********.csproj</SourceWebVirtualPath>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<OutputPath>$(BuildDir)\$(Configuration)</OutputPath>
<EnableUpdateable>true</EnableUpdateable>
<UseMerge>true</UseMerge>
<SingleAssemblyName>*********.csproj_deploy</SingleAssemblyName>
<DeleteAppCodeCompiledFiles>false</DeleteAppCodeCompiledFiles>
<UseWebConfigReplacement>false</UseWebConfigReplacement>
<DeleteAppDataFolder>false</DeleteAppDataFolder>
<VirtualDirectoryAlias>
</VirtualDirectoryAlias>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugSymbols>false</DebugSymbols>
<OutputPath>$(BuildDir)\$(Configuration)</OutputPath>
<EnableUpdateable>true</EnableUpdateable>
<UseMerge>true</UseMerge>
<SingleAssemblyName>*********.csproj_deploy</SingleAssemblyName>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'goss-test|AnyCPU' ">
<EnableUpdateable>true</EnableUpdateable>
<UseMerge>true</UseMerge>
<UseWebConfigReplacement>false</UseWebConfigReplacement>
<SingleAssemblyName>*********.csproj_deploy</SingleAssemblyName>
<OutputPath>$(BuildDir)\$(Configuration)</OutputPath>
<DeployPath>E:\dotnet-sites\eastrenintranet</DeployPath>
<DebugSymbols>false</DebugSymbols>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == '*********-intranet-dev|AnyCPU' ">
<EnableUpdateable>true</EnableUpdateable>
<UseMerge>true</UseMerge>
<UseWebConfigReplacement>false</UseWebConfigReplacement>
<SingleAssemblyName>*********.csproj_deploy</SingleAssemblyName>
<OutputPath>$(BuildDir)\$(Configuration)</OutputPath>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == '*********-intranet-live|AnyCPU' ">
<EnableUpdateable>true</EnableUpdateable>
<UseMerge>true</UseMerge>
<UseWebConfigReplacement>false</UseWebConfigReplacement>
<SingleAssemblyName>*********.csproj_deploy</SingleAssemblyName>
<OutputPath>$(BuildDir)\$(Configuration)</OutputPath>
</PropertyGroup>
<ItemGroup>
<ExcludeFromBuild Include="$(SourceWebPhysicalPath)\**\.svn\**\*" />
<ExcludeFromBuild Include="$(SourceWebPhysicalPath)\bin\*.xml" />
<ExcludeFromBuild Include="$(SourceWebPhysicalPath)\lucene\**\*" />
<ExcludeFromBuild Include="$(SourceWebPhysicalPath)\media\**\*" />
<ExcludeFromBuild Include="$(SourceWebPhysicalPath)\obj\**\*" />
<ExcludeFromBuild Include="$(SourceWebPhysicalPath)\*.csproj" />
<ExcludeFromBuild Include="$(SourceWebPhysicalPath)\**\*.user" />
<ProjectReference Include="..\..\webapp\*********.csproj">
<Project>{BF29C57D-D568-4195-9DE5-E5F179E19A0C}</Project>
<Name>*********</Name>
</ProjectReference>
<ExcludeFromBuild Include="$(SourceWebPhysicalPath)\cache\**\*" />
<ProjectReference Include="..\..\webapp\*********.csproj">
<Project>{BF29C57D-D568-4195-9DE5-E5F179E19A0C}</Project>
<Name>eastren-intranet</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<IncludeInBuild Include="$(SourceWebPhysicalPath)\**\*" Exclude="#(ExcludeFromBuild)" />
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\MSBuildCommunityTasks\MSBuild.Community.Tasks.Targets" />
<Import Project="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" />
<Target Name="CopyFilesToOutputDirectory" BeforeTargets="Rebuild">
<Copy SourceFiles="#(IncludeInBuild)" DestinationFolder="$(BuildDir)\$(Configuration)\%(RecursiveDir)" />
</Target>
<Target Name="BeforeBuild">
<RemoveDir Directories="$(BuildDir)" />
</Target>
<Target Name="BeforeMerge">
</Target>
<Target Name="AfterMerge">
</Target>
<Target Name="Rebuild" BeforeTargets="BeforeBuild">
<Message Text="*** Target: Rebuild - BEGIN" />
<!-- Copy in any configuration files overwriting any previous ones -->
<ItemGroup>
<ConfigFiles Include="..\..\config\$(Configuration)\**\*.*" Exclude="..\..\config\$(Configuration)\**\.svn\**" />
</ItemGroup>
<Message Text="*** Target: Rebuild - Copying configuration files" />
<Copy SourceFiles="#(ConfigFiles)" DestinationFolder="$(BuildDir)\$(Configuration)\%(RecursiveDir)" />
<!-- Create a ZIP archive of the entire built site -->
<ItemGroup>
<ZipFiles Include="$(BuildDir)\$(Configuration)\**\*.*" />
</ItemGroup>
<MakeDir Directories="$(BuildDir)" Condition="!Exists('$(BuildDir)')" />
<Message Text="*** Target: Rebuild - Zipping work directory $(BuildDir)\$(Configuration)\ " />
<Zip Files="#(ZipFiles)" WorkingDirectory="$(BuildDir)\$(Configuration)\" ZipFileName="$(BuildDir)\$(ProjectName)-$(Configuration)$(Version).zip" ZipLevel="9" />
<!-- Auto deploy new site if on test -->
<ItemGroup Condition="$(DeployPath) != ''">
<SiteFiles Include="$(DeployPath)\**\*.*" Exclude="$(DeployPath)\.htaccess" />
</ItemGroup>
<Message Text="*** Target: Rebuild - Removing deployment directory $(DeployPath) " />
<Delete Condition="$(DeployPath) != ''" Files="#(SiteFiles)" />
<Message Text="*** Target: Rebuild - Unzipping site file $(DeployPath) " />
<Unzip Condition="$(DeployPath) != ''" ZipFileName="$(BuildDir)\$(ProjectName)-$(Configuration)$(Version).zip" TargetDirectory="$(DeployPath)" />
<Message Text="*** Target: Rebuild - END " />
</Target>
</Project>
How do i resolve this issue?
I can build the solution ok without any errors and the site displays ok on localhost. MSBUILD also runs ok and on the face of it, i can't see an issue with the output.
Please advise
thanks
Visual Studio 2013/2015 don't support Setup and deployment -projects out of the box. Install extension to enable those:
https://marketplace.visualstudio.com/items?itemName=VisualStudioProductTeam.MicrosoftVisualStudio2015InstallerProjects
Using MSBuild I include a solution>
<ItemGroup>
<ProjectToBuild Include="$(SVNLocalPath)\$(SolutionName)"> </ProjectToBuild>
</ItemGroup>
I need to include all the *.csproj file from the solution with the condition of the proj file contain or define a property; for example if x.csproj contain a defined property "TestProjectType" would like to include the project into my itemGroup
something like this
<Target Name = "TestProperties">
<Message Text="TestProperties"/>
<ItemGroup>
<AllProj Include="$(SVNLocalPath)\*.csproj"/>
<AllTestProj Include="%(AllProj.Identity)" Condition="%(AllProj.ProjectTypeGuids)=={3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}"/>
</ItemGroup>
<Message Text="#(AllTestProj )"/>
</Target>
Thanks
You can achieve that through custom task.
A simple sample to check a property (test) in all projects exclude current project of current solution:
<UsingTask TaskName="GetPropertyTask" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v12.0.dll">
<ParameterGroup>
<ProjectFile ParameterType="System.String" Required="true" />
<BuildOutput ParameterType="System.String[]" Output="true" />
</ParameterGroup>
<Task>
<Reference Include="System.Xml"/>
<Reference Include="Microsoft.Build"/>
<Using Namespace="Microsoft.Build" />
<Using Namespace="Microsoft.Build.Evaluation" />
<Using Namespace="Microsoft.Build.Utilities" />
<Code Type="Fragment" Language="cs">
<![CDATA[
var properties = new Dictionary<string, string>
{
{ "Configuration", "$(Configuration)" },
{ "Platform", "$(Platform)" }
};
//Log.LogMessage(MessageImportance.High, "customLog");
// Log.LogMessage(MessageImportance.High, ProjectFile);
var collection = new ProjectCollection(properties);
var project = collection.LoadProject(ProjectFile);
ProjectProperty pp = project.Properties.Where(p => p.Name == "MyCustomProperty").FirstOrDefault();
string customValue = pp==null?"empty":pp.EvaluatedValue;
BuildOutput = new String[] { customValue };
]]></Code>
</Task>
</UsingTask>
<Target Name="AfterBuild">
<GetPropertyTask ProjectFile="%(ProjectToScan.FullPath)">
<Output ItemName="ProjectToScanOutput" TaskParameter="BuildOutput"/>
</GetPropertyTask>
<Message Text="ClassLibrary1" Importance="high" Condition="'%(ProjectToScanOutput.Identity)' == 'test'" />
</Target>
More information, please refer to this article.
I have a Visual Studio solution with 2 Windows Phone 7 projects. One is the main project, the other links its xaml pages from the first.
I try to modify the .csproj file of the second project in order to preprocess its linked pages by a custom task. My modifications are based upon the sample solution of this blog post :
Xaml pages are indeed processed by my custom task but the output files are not used in continuation of the compiling process. I guess this is the involved portion of code :
<ItemGroup>
<ProcessedPages Include="#(Page->'%(Link)')" />
<!-- Remove the original (linked) pages so that they are not compiled. -->
<Page Remove="#(Page)" Condition="('%(Page.Link)' != '')" />
<!-- Include the processed pages instead. -->
<Page Include="#(ProcessedPages)" />
</ItemGroup>
How to modify it so MarkupCompilePass1 use output file of the PreprocessorTask task ?
By the way, I don’t get what is the value of #(Page->'%(Link)') during compilation.
Compelete project file for reference :
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<UsingTask TaskName="XamlPreprocessor.PreprocessorTask" AssemblyFile="C:\Users\Louis\Documents\visual studio 2010\Projects\XamlPreprocessor\XamlPreprocessor\bin\Debug\XamlPreprocessor.exe" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>10.0.20506</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{C835DF63-2335-4946-B343-186E556C4FEC}</ProjectGuid>
<ProjectTypeGuids>{C089C8C0-30E0-4E22-80C0-CE093F111A43};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}
</ProjectTypeGuids>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>ProcessorTest</RootNamespace>
<AssemblyName>ProcessorTest</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<SilverlightVersion>$(TargetFrameworkVersion)</SilverlightVersion>
<TargetFrameworkProfile>WindowsPhone71</TargetFrameworkProfile>
<TargetFrameworkIdentifier>Silverlight</TargetFrameworkIdentifier>
<SilverlightApplication>true</SilverlightApplication>
<SupportedCultures>
</SupportedCultures>
<XapOutputs>true</XapOutputs>
<GenerateSilverlightManifest>true</GenerateSilverlightManifest>
<XapFilename>ProcessorTest.xap</XapFilename>
<SilverlightManifestTemplate>Properties\AppManifest.xml</SilverlightManifestTemplate>
<SilverlightAppEntry>ProcessorTest.App</SilverlightAppEntry>
<ValidateXaml>true</ValidateXaml>
<ThrowErrorsInValidation>true</ThrowErrorsInValidation>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>Bin\Debug</OutputPath>
<DefineConstants>TRACE;DEBUG;SILVERLIGHT;WINDOWS_PHONE;WP8</DefineConstants>
<NoStdLib>true</NoStdLib>
<NoConfig>true</NoConfig>
<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;SILVERLIGHT;WINDOWS_PHONE</DefineConstants>
<NoStdLib>true</NoStdLib>
<NoConfig>true</NoConfig>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.Phone" />
<Reference Include="Microsoft.Phone.Interop" />
<Reference Include="System.Windows" />
<Reference Include="system" />
<Reference Include="System.Core" />
<Reference Include="System.Net" />
<Reference Include="System.Xml" />
<Reference Include="mscorlib.extensions" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\Appli2\MainPage.xaml.cs">
<Link>MainPage.xaml.cs</Link>
<DependentUpon>MainPage.xaml</DependentUpon>
</Compile>
<Compile Include="..\Appli2\Page2.xaml.cs">
<Link>Page2.xaml.cs</Link>
<DependentUpon>Page2.xaml</DependentUpon>
</Compile>
<Compile Include="App.xaml.cs">
<DependentUpon>App.xaml</DependentUpon>
</Compile>
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<ApplicationDefinition Include="App.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</ApplicationDefinition>
</ItemGroup>
<ItemGroup>
<None Include="Properties\AppManifest.xml" />
<None Include="Properties\WMAppManifest.xml" />
</ItemGroup>
<ItemGroup>
<Content Include="ApplicationIcon.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Background.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="SplashScreenImage.jpg" />
</ItemGroup>
<ItemGroup>
<Page Include="..\Appli2\MainPage.xaml">
<Link>MainPage.xaml</Link>
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="..\Appli2\Page2.xaml">
<Link>Page2.xaml</Link>
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Microsoft\Silverlight for Phone\$(TargetFrameworkVersion)\Microsoft.Silverlight.$(TargetFrameworkProfile).Overrides.targets" />
<Import Project="$(MSBuildExtensionsPath)\Microsoft\Silverlight for Phone\$(TargetFrameworkVersion)\Microsoft.Silverlight.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>
-->
<PropertyGroup>
<MarkupCompilePass1DependsOn>
$(CompileXamlDependsOn)
PreprocessXaml;
</MarkupCompilePass1DependsOn>
</PropertyGroup>
<Target Name="PreprocessXaml">
<!-- Run the preprocessor on every page that is added to the project as link. The processed file will be saved at the link position. -->
<!--<Exec Condition="('%(Page.Link)' != '')" Command="XamlPreprocessor.exe "%(Page.FullPath)" "%(Page.Link)""/>-->
<PreprocessorTask Symbols="$(DefineConstants)" File="%(Page.FullPath)" OutName="%(Page.Link)" Condition="('%(Page.Link)' != '')" />
<Copy SourceFiles="%(Page.Link)" DestinationFolder="C:\Users\Louis\Desktop\temp\" />
<ItemGroup>
<ProcessedPages Include="#(Page->'%(Link)')" />
<!-- Remove the original (linked) pages so that they are not compiled. -->
<Page Remove="#(Page)" Condition="('%(Page.Link)' != '')" />
<!-- Include the processed pages instead. -->
<Page Include="#(ProcessedPages)" />
</ItemGroup>
</Target>