Powershell Tools module project build not working correctly - powershell

I have Powershell Tools project in Visual Studio 2015 defined like this:
<?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>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>6CAFC0C6-A428-4d30-A9F9-700E829FEA51</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>MyApplication</RootNamespace>
<AssemblyName>MyApplication</AssemblyName>
<Name>PS.TEST</Name>
<DebugArguments>
</DebugArguments>
<Author />
<CompanyName />
<Copyright />
<Description />
<Version>1.0.0.1</Version>
<Guid>29a8500a-c449-43f5-b9ba-610546db8cc2</Guid>
<FormatsToProcess />
<FunctionsToProcess />
<ModuleList>
</ModuleList>
<ModuleToProcess />
<NestedModules />
<TypesToProcess />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Compile Include="PS-TEST.psd1" />
<Compile Include="PS-TEST.psm1" />
<Compile Include="Tools\Release.ps1" />
</ItemGroup>
<ItemGroup>
<Folder Include="Files\" />
<Folder Include="Tools\" />
<Folder Include="Public\" />
<Folder Include="Private\" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Target Name="CoreCompile" />
<Target Name="Build">
<Exec Command="Powershell.exe Tools\Release.ps1 $(version)" />
</Target>
</Project>
When I build whole solution "Build" task Exec command is not performed. Why?
When I build this with msbuild console application it succeeds and performs "Build" task Exec command, however "Build command" in Visual Studio 2015 Community is not displayed for this project when I right click the project node on solution explorer. How to enable this?
I've already added node <Target Name="CoreCompile" /> but no effect - the command is still not shown in the UI. Is there something still missing in the XML?

The PowerShell Tools extension does not define a Visual Studio command to "build" a PowerShell module project. If you right click the project in the solution explorer you'll notice there is no build option.
However, there is an option beneath the Build menu. I assume that this is just standard chrome of Visual Studio, not the doing of the extension provider. Because clicking this is essentially a no-op.
Currently, msbuild is the tool to accomplish what you need.
You can file an issue here: https://github.com/adamdriscoll/poshtools/issues

Related

Why is dotnet restore working and dotnet build failing on nuget packages from nuget.org?

I've read the following post about this problem, but with my solution and nuget file are located in the same folder, the task dotnet build fails, while the previous dotnet restore succeed.
I have no HintPath in my project, just direct references to Packages.
What is confusing to me is that somehow, the restore task is trying to look at .net core 5 assemblies in my private nuget feed (Azure Artifacts). For instance:
GET https://pkgs.dev.azure.com/mycompany/_packaging/58afa52a-c2d4-4346-bfd2-1bf77f29075e/nuget/v3/flat2/system.servicemodel.security/index.json
Unauthorized https://pkgs.dev.azure.com/mycompany/_packaging/58afa52a-c2d4-4346-bfd2-1bf77f29075e/nuget/v3/flat2/system.servicemodel.duplex/index.json 52ms
It seems that nuget.org is simply ignored.
Following is the content of my nuget.config and project file:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<clear/>
<add key="nuget" value="https://api.nuget.org/v3/index.json" />
<add key="Dev" value="https://pkgs.dev.azure.com/rtetech/_packaging/Dev/nuget/v3/index.json" />
</packageSources>
</configuration>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<AssemblyVersion>0.0.4</AssemblyVersion>
<FileVersion>0.0.4</FileVersion>
<RootNamespace>MyCompany.Common</RootNamespace>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
<Version>0.0.4-pre</Version>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="CommonDatabase.EFCore" Version="1.4.10" />
<PackageReference Include="CryptographyTools.Portable" Version="2.0.4" />
<PackageReference Include="Dapper.StrongName" Version="1.50.5" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="MyCompanyLog.Standard" Version="1.3.3" />
<PackageReference Include="System.ServiceModel.Duplex" Version="4.8.*" />
<PackageReference Include="System.ServiceModel.Federation" Version="4.8.*" />
<PackageReference Include="System.ServiceModel.Http" Version="4.8.*" />
<PackageReference Include="System.ServiceModel.NetTcp" Version="4.8.*" />
<PackageReference Include="System.ServiceModel.Security" Version="4.8.*" />
</ItemGroup>
</Project>
My solution to this problem is to still use dotnet restore in conjunction with dotnet build with the --no-restore option on the command line for the latter. Now this works like a charm...
If you are able to use the .NET 6 SDK to build your project (you really should upgrade the taget framework as well, .NET 5 is end of life since May 2022) you can use something called "package source mapping" to say which packages should be retrieved from which source.
In your case it would look something like this.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<clear />
<add key="nuget" value="https://api.nuget.org/v3/index.json" />
<add key="Dev" value="https://pkgs.dev.azure.com/rtetech/_packaging/Dev/nuget/v3/index.json" />
</packageSources>
<packageSourceMapping>
<packageSource key="Dev">
<package pattern="MyCompanyLog.*" />
</packageSource>
<packageSource key="nuget">
<package pattern="*" />
</packageSource>
</packageSourceMapping>
</configuration>
This might also speed up the restore process since it isn't checking every source for every package.
It should work to use this with your .NET 5 project as long as you use the .NET 6 SDK.
https://learn.microsoft.com/en-us/nuget/consume-packages/package-source-mapping

Azure pipeline error: The type or namespace name 'Azure' could not be found (are you missing a using directive or an assembly reference?

I have a build pipeline in azure devops but getting the error below.
The type or namespace name 'Azure' could not be found (are you missing
a using directive or an assembly reference?
This error appears during my MSbuild task, the previous Nuget restore task works fine.
This is my project file
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Build">
<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>{01511C7D-0BB5-4EF9-9B86-FE2B7B1E73DB}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>GraphSDK</RootNamespace>
<AssemblyName>GraphSDK</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
</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="System" />
<Reference Include="System.Core" />
<Reference Include="System.Drawing" />
<Reference Include="System.IdentityModel" />
<Reference Include="System.Numerics" />
<Reference Include="System.Security" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="GraphClient.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Samples\Assignment.cs" />
<Compile Include="Samples\Submission.cs" />
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Azure.Identity">
<Version>1.5.0</Version>
</PackageReference>
<PackageReference Include="Microsoft.Graph">
<Version>4.7.0</Version>
</PackageReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
And this is my MSbuild task, any idea what is the reason of the error or probably something related to my project?
BTW, it builds fine locally in VS2019.
How Did I solve it?
It seems there is a difference on how your project takes the nuget packages.
I had added them from Solution level, I mean.
Right click on the solution.
Manage Nuget Packages for Solution...
What worked was to remove the Nuget packages and add back but from Project level (I have 3 projects in my solution).
Right click on the project.
Manage Nuget Packages..
And install back all your packages (project by project).
Not sure why but it worked!!

Ant Builder for SASS in Zend Studio (Eclipse) "Is A Directory" Error

The build script I am using:
<?xml version="1.0" encoding="UTF-8"?>
<project basedir="." default="sass">
<target name="sass">
<apply dest="./sass" executable="sassy.bat">
<srcfile />
<targetfile />
<mapper from="*.scss" to="*.css" type="glob"/>
<fileset dir="./sass" includes="**/*.scss" />
</apply>
</target>
</project>
And it works great, with the condition that I have this external sassy.bat script on my %%PATH%%.
sass %1 %2
It compiles sass/*.scss files and puts the *.css in the same directory. However, if I don't use my sassy.bat and rather just use sass.bat it produces:
ruby.exe: Is a directory -- C:/project/sass (LoadError)
But in theory it should be running the same thing. Any idea what I'm doing wrong?
I ended up solving this problem recently. The first step is to ensure that the builder is set to use a "Separate JRE" (Zend Studio's). The second step was to update my buildfile to the following:
<?xml version="1.0" encoding="UTF-8"?>
<project basedir="." default="sass">
<target name="sass">
<exec osfamily="windows" vmlauncher="false" executable="sass">
<arg value="--update" />
<arg value="scss/:css/" />
<arg value="--style=compressed" />
</exec>
</target>
</project>
The key was to set the vmlauncher attribute to false on Windows.

Jenkins with JSLint and Violations plugin

I currently configured a jenkins server that validates my project on javascript errors with JSlint ( with ant). Now i want to show all the errors with the violation plugin. I can generate an xml with all the errors. But it doesn't show this in the graph.
This is my build.xml:
<?xml version="1.0" encoding="UTF-8"?>
<taskdef name="jslint"
classname="com.googlecode.jslint4java.ant.JSLintTask"
classpath="jslint/jslint4java-2.0.2.jar" />
<property name="reports.dir" value="reports" />
<target name="clean" description="Removes output files created by other targets.">
<delete dir="${reports.dir}" failonerror="true" />
</target>
<target name="jslint" depends="clean">
<mkdir dir="reports" />
<jslint options="white,undef,plusplus,newcap,vars,indent=4">
<predef>jQuery, setTimeout, history, window, document</predef>
<formatter type="xml" destfile="jslint_results.xml"/>
<fileset dir="" includes="**/*.js" excludes="lib/*.js" />
</jslint>
</target>
This is my violations setting:
The pattern is relative to your workspace. So if your report 'lives' in <WORKSPACE>/reports the pattern should be reports/jslint_results.xml or **/jslint_results.xml

Unable to open Facebook C# SDK canvas samples. IIS 6?

Downloaded Facebook C# SDK 5.4.1 from here.
I've been through the CS-WinForms solution which works fine. I'm now trying to open the CS-Canvas-AspNetWebForms-JsSdk and CS-Canvas-AspNetWebForms-WithoutJsSdk solutions but I get the following error in VS 2010:
D:\VSProjects\...\CS-Canvas-AspNetWebForms-WithoutJsSdk.csproj : error :
The Web Application Project CS-Canvas-AspNetWebForms-WithoutJsSdk is configured
to use IIS. To access local IIS Web sites, you must install the following IIS
components:
IIS 6 Metabase and IIS 6 Configuration Compatibility
ASP.NET
In addition, you must run Visual Studio in the context of an administrator account.
I'm running on Windows 7 (64 bit) so I really don't want to install IIS 6. Can I just run this solution using the built-in VS Cassini web server that I use for everything else?
UPDATE:
Apparently I need to edit the .csproj file by hand. The contents are shown below. Can anyone tell me which changes I need to make?
<?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>
</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{7A74691E-66DF-4DAA-B9A7-D5428E13B5A9}</ProjectGuid>
<ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>CS_Canvas_AspNetWebForms_JsSdk</RootNamespace>
<AssemblyName>CS-Canvas-AspNetWebForms-JsSdk</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<UseIISExpress>true</UseIISExpress>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\</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\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Facebook">
<HintPath>..\..\Bin\Release\net40-client\Facebook.dll</HintPath>
</Reference>
<Reference Include="Facebook.Web">
<HintPath>..\..\Bin\Release\net40\Facebook.Web.dll</HintPath>
</Reference>
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Web.DynamicData" />
<Reference Include="System.Web.Entity" />
<Reference Include="System.Web.ApplicationServices" />
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Core" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Web.Extensions" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Drawing" />
<Reference Include="System.Web" />
<Reference Include="System.Xml" />
<Reference Include="System.Configuration" />
<Reference Include="System.Web.Services" />
<Reference Include="System.EnterpriseServices" />
</ItemGroup>
<ItemGroup>
<Content Include="Default.aspx" />
<Content Include="Facebook\Default.aspx" />
<Content Include="Facebook\FacebookLoginControl.ascx" />
<Content Include="Scripts\jquery-1.6.2-vsdoc.js" />
<Content Include="Scripts\jquery-1.6.2.js" />
<Content Include="Scripts\jquery-1.6.2.min.js" />
<Content Include="Web.config" />
<Content Include="Web.Debug.config">
<DependentUpon>Web.config</DependentUpon>
</Content>
<Content Include="Web.Release.config">
<DependentUpon>Web.config</DependentUpon>
</Content>
</ItemGroup>
<ItemGroup>
<Compile Include="Default.aspx.cs">
<DependentUpon>Default.aspx</DependentUpon>
<SubType>ASPXCodeBehind</SubType>
</Compile>
<Compile Include="Default.aspx.designer.cs">
<DependentUpon>Default.aspx</DependentUpon>
</Compile>
<Compile Include="Facebook\Default.aspx.cs">
<DependentUpon>Default.aspx</DependentUpon>
<SubType>ASPXCodeBehind</SubType>
</Compile>
<Compile Include="Facebook\Default.aspx.designer.cs">
<DependentUpon>Default.aspx</DependentUpon>
</Compile>
<Compile Include="Facebook\FacebookLoginControl.ascx.cs">
<DependentUpon>FacebookLoginControl.ascx</DependentUpon>
<SubType>ASPXCodeBehind</SubType>
</Compile>
<Compile Include="Facebook\FacebookLoginControl.ascx.designer.cs">
<DependentUpon>FacebookLoginControl.ascx</DependentUpon>
</Compile>
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<Content Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" />
<ProjectExtensions>
<VisualStudio>
<FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}">
<WebProjectProperties>
<UseIIS>True</UseIIS>
<AutoAssignPort>True</AutoAssignPort>
<DevelopmentServerPort>1220</DevelopmentServerPort>
<DevelopmentServerVPath>/</DevelopmentServerVPath>
<IISUrl>http://localhost:1220/</IISUrl>
<NTLMAuthentication>False</NTLMAuthentication>
<UseCustomServer>False</UseCustomServer>
<CustomServerUrl>
</CustomServerUrl>
<SaveServerSettingsInUserFile>False</SaveServerSettingsInUserFile>
</WebProjectProperties>
</FlavorProperties>
</VisualStudio>
</ProjectExtensions>
<!-- 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>
Right-click on the project and change the webserver settings to use cassini. If you cannot get the project to load at all, then you will need to hand edit the .csproj file and change the web server settings by hand.