Open bezysoftware opened 9 years ago
V3 was released in error - I'd have removed it if I could.
Basically, I thought my patches for Roslyn were applied, but they will not be available until Roslyn stable ships (which should be soonish). That said, it shouldn't lead to the error you're seeing. Anyway, once Roslyn v1 ships I'll release PCLMock v3.1 and will ping you here to retry with those binaries.
Alright, I'll wait for Roslyn, thanks for the info
Hi,
v3.1 has been released and I've successfully integrated the code generation (T4 in my case, but I also tried via the console) in my own large project. Could you please try again and let me know how you get on?
Thanks
Hi, just tried v3.1 + T4 on a clean new project and still fails :(, VS2013 Premium, Windows 7, .NET 4.5 project.
I will try on Windows 10 & VS2015 when I get home.
thanks @bezysoftware I'd appreciate you trying that. I assume it's the same error you're getting?
BTW, my setup is Win8.1 VS2015 RTM, .NET 4.5
I just tried multiple things (all on Windows 10 RTM) VS 2015 Universal Project: didn't even create Mocks.tt and Mocks.xml, after I created them manually I get "Could not find packages directory relative to the template's directory". It seems the Universal Project uses completely different structure for packages, there is even no packages.config VS 2015 .NET 4.6: WORKS
VS 2013 Windows 8.1 Project: Missing TypedParts (as in first post) VS 2013 .NET 4.6: Missing TypedParts (as in first post)
@bezysoftware thanks for that. Weird - I'll have a look when I get some time (which might not be for a while).
Seems there are some big changes with latest nuget for uwp... http://blog.nuget.org/20150729/Introducing-nuget-uwp.html
Thanks for the link. NuGet 3 sounds like a WIP. Creating the content files manually (Mocks.tt Mocks.xml) is your only choice right now until they add support back in for content files. As for the other issue, I'll try to take a look at some point, but if it's a big issue I might have to postpone a resolution until NuGet 3 is bedded down more.
Have the same error (Cannot find System.Coposition.TypedParts). Windows 8 Pro / VisualStudio 2013 / Portable project with targeting Windows 8.1 and Windows Phone 8.1. When I use PCLMockCodeGen tool all works fine.
I'll try to submit a PR at some point, but using the T4 generator on UWP fails (even after manually copying over 'Mocks.tt' and 'Mocks.xml' because NuGet 3 packages are stored globally in your user profile, instead of "packages" project in your solution. This worked for me:
private void HookAssemblyResolution()
{
// Get Packages Directory
string packagesDirectory = Environment.ExpandEnvironmentVariables("%userprofile%\\.nuget\\packages");
if (packagesDirectory == null)
{
throw new InvalidOperationException("Could not find packages directory in your user profile.");
}
this.Debug("packages directory: {0}", packagesDirectory);
// Get T4 Code Generation Directory
var packageDirectories = Directory.GetDirectories(packagesDirectory, "PCLMock.CodeGeneration.T4.*");
if (packageDirectories.Length == 0)
{
throw new InvalidOperationException("Could not find PCLMock.CodeGeneration.T4 package in packages directory (" + packagesDirectory + ").");
}
var packageDirectory = packageDirectories.First();
this.Debug("package directory: {0}", packageDirectory);
// Get first version subfolder
var packageVersionDirectories = Directory.GetDirectories(packageDirectory);
if (packageDirectories.Length == 0)
{
throw new InvalidOperationException("Could not find any versions of PCLMock.CodeGeneration.T4 package in package directory (" + packageDirectory + ").");
}
var packageVersionDirectory = packageVersionDirectories.First(); // TODO: Could do this smarter?
// Get tools directory
var assembliesDirectory = Path.Combine(packageVersionDirectory, "tools");
this.Debug("assemblies directory: {0}", assembliesDirectory);
if (!Directory.Exists(assembliesDirectory))
{
throw new InvalidOperationException("Package directory " + packageVersionDirectory + " was found but no 'tools' subdirectory was found within.");
}
AppDomain.CurrentDomain.AssemblyResolve += (s, e) =>
{
this.Debug("resolve: {0}", e.Name);
var matches = Directory.GetFiles(assembliesDirectory, e.Name + ".dll", SearchOption.TopDirectoryOnly);
if (matches.Length == 0)
{
this.Debug("Failed to find assembly in assemblies directory ({0}) named '{1}'.", assembliesDirectory, e.Name);
return null;
}
else if (matches.Length > 1)
{
this.Debug("Found more than one potential match for '{0}' in assemblies directory ({0}). Bailing.", e.Name, assembliesDirectory);
return null;
}
var match = matches.First();
this.Debug("match: {0}", match);
return Assembly.LoadFrom(match);
};
}
I just tried to use the T4 generator, but when I try to run the custom tool, I get following error:
It's .net 4.5 project